go-gl / gl

Go bindings for OpenGL (generated via glow)
MIT License
1.07k stars 74 forks source link

all: Represent GLsync as uintptr, not unsafe.Pointer. #72

Closed dmitshur closed 6 years ago

dmitshur commented 7 years ago

Regenerate all bindings after generator change in go-gl/glow#79.

Done with latest version of glow:

go generate -tags=gen github.com/go-gl/gl

Resolves #71.

/cc @errcw @dominikh

errcw commented 7 years ago

LGTM, should merge pending Travis build confirmation.

dmitshur commented 7 years ago

It fails to compile:

$ go test ./v4.5-core/gl
# github.com/go-gl/gl/v4.5-core/gl
v4.5-core/gl/package.go:5490: cannot convert sync (type uintptr) to type C.GLsync
v4.5-core/gl/package.go:5662: cannot convert ret (type C.GLsync) to type uintptr
v4.5-core/gl/package.go:5766: cannot convert sync (type uintptr) to type C.GLsync
v4.5-core/gl/package.go:5972: cannot convert ret (type C.GLsync) to type uintptr
v4.5-core/gl/package.go:6480: cannot convert sync (type uintptr) to type C.GLsync
v4.5-core/gl/package.go:6803: cannot convert sync (type uintptr) to type C.GLsync
v4.5-core/gl/package.go:8205: cannot convert sync (type uintptr) to type C.GLsync
errcw commented 7 years ago

Alas. Go is unhappy converting between uintptr and a C pointer type. Which is a little strange because we're already doing the same thing for GLhandleARB which maps to void * on Mac OS. Maybe void* is special compared to an anonymous struct pointer?

It might be safe to do a just-in-time conversion from uintptr to unsafe.Pointer (but the GC may still catch this at exactly the wrong moment)? Alternatively we could change the C function signature and cast the value there, though that's not yet well supported by glow.

errcw commented 6 years ago

Dropping this PR given we implemented a slightly different fix in Glow.