Skip to content

Commit ee6562c

Browse files
committed
document where to find examples and guard go-gl builds
1 parent 44e5046 commit ee6562c

File tree

3 files changed

+56
-1
lines changed

3 files changed

+56
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ Offshoot from [this project](https://github.com/soypat/sdf/pull/13). Is WIP.
2121
## Part design - NPT Flange example.
2222
This was converted from the [original example](https://github.com/soypat/sdf/blob/main/examples/npt-flange/flange.go). See [README](https://github.com/soypat/sdf/tree/main/examples) for images.
2323

24+
25+
See working example under [examples](./examples/) directory. Run on GPU with `-gpu` flag:
26+
```sh
27+
go run ./examples/npt-flange -gpu
28+
```
29+
30+
31+
2432
```go
2533
const (
2634
tlen = 18. / 25.4

gleval/gpu.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build !tinygo
1+
//go:build !tinygo && cgo
22

33
package gleval
44

gleval/gpu_nocgo.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//go:build tinygo || !cgo
2+
3+
package gleval
4+
5+
import (
6+
"errors"
7+
"io"
8+
9+
"github.com/soypat/glgl/math/ms2"
10+
"github.com/soypat/glgl/math/ms3"
11+
)
12+
13+
var errNoCGO = errors.New("GPU evaluation requires CGo and is not supported on TinyGo")
14+
15+
// NewComputeGPUSDF3 instantiates a [SDF3] that runs on the GPU.
16+
func NewComputeGPUSDF3(glglSourceCode io.Reader, bb ms3.Box) (*SDF3Compute, error) {
17+
return nil, errNoCGO
18+
}
19+
20+
type SDF3Compute struct {
21+
bb ms3.Box
22+
}
23+
24+
func (sdf *SDF3Compute) Bounds() ms3.Box {
25+
return sdf.bb
26+
}
27+
28+
func (sdf *SDF3Compute) Evaluate(pos []ms3.Vec, dist []float32, userData any) error {
29+
return nil, errNoCGO
30+
}
31+
32+
// NewComputeGPUSDF2 instantiates a [SDF2] that runs on the GPU.
33+
func NewComputeGPUSDF2(glglSourceCode io.Reader, bb ms2.Box) (*SDF2Compute, error) {
34+
return nil, errNoCGO
35+
}
36+
37+
type SDF2Compute struct {
38+
bb ms2.Box
39+
}
40+
41+
func (sdf *SDF2Compute) Bounds() ms2.Box {
42+
return sdf.bb
43+
}
44+
45+
func (sdf *SDF2Compute) Evaluate(pos []ms2.Vec, dist []float32, userData any) error {
46+
return errNoCGO
47+
}

0 commit comments

Comments
 (0)