Closed rcoreilly closed 3 years ago
Yup, this new checker cascades quite a lot.
The core issue here is the signature of VertexAttribPointer()
, which has unsafe.Pointer
as the last parameter. The fix would be to change the type to be uintptr_t
in the C code - which, for this method, is more fitting as it takes arbitrary offset numbers.
See also: https://golang.org/doc/go1.14#compiler
edit: I believe #80 and the discussion there will become relevant as well now.
@neclepsio could you submit a PR to fix this issue in the main package?
@rcoreilly I did nothing but running what already done by @dertseha for issue #80. There is ongoing discussion in that issue on what and how exactly to fix. I doubt a pull request with only the result their own generator would be useful: they just need the time to think what to do. Since I needed a fix as soon as possible, and one was already available but not so easy to use, I made a fork so that everyone in my position can use it in the meantime.
For clarification why #135 closes this issue: Instead of calling gl.VertexAttribPointer()
the code needs to call the newly available gl.VertexAttribPointerWithOffset()
- like this:
gl.VertexAttribPointerWithOffset(uint32(v.handle), int32(v.typ.Vec), gpu.TheGPU.Type(v.typ.Type), false, int32(str*4), uintptr(off*4))
Note the change in type of the last argument.
There are a few more overloads with WithOffset
in their name. There might be more functions that need this treatment - see READMEs of go-gl/glow
and go-gl/gl
for more details on checkptr
and overloads.
as of version 1.14, the race detector enables checkptr https://golang.org/doc/go1.14#compiler which fails on PtrOffset, at least for example in VertexAttribPointer:
Not sure there is much to be done about this given the logic of checkptr but just in case someone else hits this obstacle, here's how to overcome it:
go build -race -gcflags=all=-d=checkptr=0