View Full Version : glVertexPointer and glDrawArrays data transfer question

10-06-2012, 10:03 PM
Is it valid to update the data pointed at by the vertex pointer without updating the vertex pointer?
That is, will I have a problem with the following pseudo code:

glVertexPointer(4, GL_FLOAT, 1, pointer);

pointer[0] = some new value;


Will the updated data _always_ be transmitted or is this implementation dependent?

Alfonse Reinheart
10-06-2012, 10:29 PM
It's funny that you asked this question today, as earlier I made an edit to the Synchronization (http://www.opengl.org/wiki/Synchronization) page of the Wiki addressing this very issue.

In short, the way the *Pointer functions work when pulling from client memory is that, whenever you issue a rendering command that pulls from client memory, OpenGL must have finished reading that memory by the time the rendering command returns.

So yes; given your code, the first rendering command will not see the changes from your "some new value" stuff, and the second rendering command will. Always.

Incidentally, one of the reasons why the glDrawRangeElements function was so important to performance once upon a time is precisely this: it's hard to tell what range of vertex indices will be pulled when doing indexed rendering. So glDrawElements had to walk the index list to build the range. glDrawRangeElements made that unnecessary, thus making rendering faster.

Of course, we've got buffer objects now, so it's not as important.