Reputation: 34396
The specification for the glVertexAttribPointer
is as follows:
void glVertexAttribPointer( GLuint index,
GLint size,
GLenum type,
GLboolean normalized,
GLsizei stride,
const GLvoid * pointer);
Given that the last parameter is just a 4-byte integer offset, why does OpenGL expect it to be passed in as a void pointer?
Upvotes: 12
Views: 3796
Reputation: 54592
One way of looking at it is that the last argument is always a pointer:
At least that's the only logical explanation I could ever find.
Personally, I think that overloading the entry point this way was a very unfortunate decision, for a number of reasons:
In languages like Java, you typically end up with overloaded versions of the function that accept different types. As a somewhat curious historical note, the overloaded version with an int
argument was missing in the initial version of the GLES20
bindings in Android, which meant that you could not use VBOs from Java. So this has tripped up more that just the occasional casual OpenGL programmer.
Upvotes: 3
Reputation: 72241
Legacy.
That argument had a different meaning before VBOs: you'd keep the vertex data in client memory and pass the address of the array (see glEnableClientState and such).
Now the last parameter can have 2 meanings (offset for buffer objects, address for client state arrays). Khronos did not provide a separate version for gl*Pointer
functions for buffer objects, so you need to do this awkward cast.
Upvotes: 16