Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In OpenGL, why does glVertexAttribPointer require the "pointer" argument to be passed in as void*?

Tags:

opengl

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?

like image 614
Nathan Ridley Avatar asked Jan 21 '15 09:01

Nathan Ridley


1 Answers

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.

like image 137
Kos Avatar answered Oct 13 '22 23:10

Kos