Skip to content

Commit

Permalink
document where to find examples and guard go-gl builds
Browse files Browse the repository at this point in the history
  • Loading branch information
soypat committed Aug 17, 2024
1 parent 44e5046 commit ee6562c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ Offshoot from [this project](https://github.com/soypat/sdf/pull/13). Is WIP.
## Part design - NPT Flange example.
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.


See working example under [examples](./examples/) directory. Run on GPU with `-gpu` flag:
```sh
go run ./examples/npt-flange -gpu
```



```go
const (
tlen = 18. / 25.4
Expand Down
2 changes: 1 addition & 1 deletion gleval/gpu.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build !tinygo
//go:build !tinygo && cgo

package gleval

Expand Down
47 changes: 47 additions & 0 deletions gleval/gpu_nocgo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//go:build tinygo || !cgo

package gleval

import (
"errors"
"io"

"github.com/soypat/glgl/math/ms2"
"github.com/soypat/glgl/math/ms3"
)

var errNoCGO = errors.New("GPU evaluation requires CGo and is not supported on TinyGo")

// NewComputeGPUSDF3 instantiates a [SDF3] that runs on the GPU.
func NewComputeGPUSDF3(glglSourceCode io.Reader, bb ms3.Box) (*SDF3Compute, error) {
return nil, errNoCGO
}

type SDF3Compute struct {
bb ms3.Box
}

func (sdf *SDF3Compute) Bounds() ms3.Box {
return sdf.bb
}

func (sdf *SDF3Compute) Evaluate(pos []ms3.Vec, dist []float32, userData any) error {
return nil, errNoCGO
}

// NewComputeGPUSDF2 instantiates a [SDF2] that runs on the GPU.
func NewComputeGPUSDF2(glglSourceCode io.Reader, bb ms2.Box) (*SDF2Compute, error) {
return nil, errNoCGO
}

type SDF2Compute struct {
bb ms2.Box
}

func (sdf *SDF2Compute) Bounds() ms2.Box {
return sdf.bb
}

func (sdf *SDF2Compute) Evaluate(pos []ms2.Vec, dist []float32, userData any) error {
return errNoCGO
}

0 comments on commit ee6562c

Please sign in to comment.