About VBO mapping...

In my quest to optimize I read NVIDIA’s paper regarding VBOs.
There, one can read: “The “glVertexArray” function does a lot of setup in VBO, so to avoid redundancy, avoid calling it.”

so, if I were to do:

//first pass
glBindBufferARB(GL_ARRAY_BUFFER_ARB,1);
GlVertexPointer(3,GL_FLOAT,stride,(void*)0);
GlNormalPointer(GL_FLOAT,stride,(void*)12);

glBindBufferARB(GL_ARRAY_BUFFER_ARB,2);
GlVertexPointer(3,GL_FLOAT,stride,(void*)12);
GlNormalPointer(GL_FLOAT,stride,(void*)24);

//other passes
glBindBufferARB(GL_ARRAY_BUFFER_ARB,1);
//draw
glBindBufferARB(GL_ARRAY_BUFFER_ARB,2);
//draw

In the last case, where the drawing occurs, the binding explicit changes the pointers offsets?
If not, does binding make previous offset undefined?

In my actuall code I have two passes, where the offsets remain the samed from one pass to another and even for diferent VBOs during thoose passes. Then I figured that maybe the offsets in the second pass where doing nothing. I commented them and everything got screwed… Why? I can’t see any reason to, unless glBindBufferARB makes any previous indicated offsets invalid witch, after reading the ARB_vertex_buffer_object spec, seems wrong to me…

I would like very much for things to work like I wrote above… But it doesn’t seem that way.

[This message has been edited by KRONOS (edited 12-11-2003).]

You’ll want to look at section 2.8A.1 of the VBO spec . The second paragraph explains what you’re seeing. Basically, calling VertexPointer and friends uses both the offset specified to the function call and the currently bound vertex buffer so set the data source. That’s why VertexPointer is so costly to call. Calling BindBuffer will usually only set an internal pointer and a flag that is later used by VertexPointer.

For optimal performance on the Nvidia drivers, you want to put all of your data into the same buffers. That is, all of your vertex data should be in one buffer, all of your normal data should be one buffer (possibly the same buffer as the vertex data), etc. That may or may not be convenient for the way you have your data organized.