You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The OpenGL API has a habit of using void pointers for offsets into buffer objects, eg. in glVertexAttribPointer, glDrawElements, etc.
The only reason I see for this being done is so pointer arithmetic can be used to remove the need to multiply things by sizeof (T), however Zig does not have pointer arithmetic, leaving this as purely confusing and difficult to handle, without any ergonomic benefit.
zgl currently uses ?usize for the offset parameter to vertexAttribPointer, and ?*const c_void for the parameter to glDrawElements and glDrawElementsInstanced. The way the former is converted into the C type will cause checked undefined behaviour if 0 is passed in, and the latter is difficult to deal with as discussed above.
I propose changing all of these functions, as well as any future functions making use of this kind of offset, to use usize, which can be converted into a *allowzero c_void for passing to C.
The text was updated successfully, but these errors were encountered:
The OpenGL API has a habit of using void pointers for offsets into buffer objects, eg. in
glVertexAttribPointer
,glDrawElements
, etc.The only reason I see for this being done is so pointer arithmetic can be used to remove the need to multiply things by
sizeof (T)
, however Zig does not have pointer arithmetic, leaving this as purely confusing and difficult to handle, without any ergonomic benefit.zgl currently uses
?usize
for the offset parameter tovertexAttribPointer
, and?*const c_void
for the parameter toglDrawElements
andglDrawElementsInstanced
. The way the former is converted into the C type will cause checked undefined behaviour if0
is passed in, and the latter is difficult to deal with as discussed above.I propose changing all of these functions, as well as any future functions making use of this kind of offset, to use
usize
, which can be converted into a*allowzero c_void
for passing to C.The text was updated successfully, but these errors were encountered: