VBO BindBufferARB scope


I don’t know if I’m pushing the abilities of VBO further than it should or not, but I’m seeing a problem on both NVIDIA and ATI cards of the following.

I have a morphing geometry. Thus I want to store positions and normals in a dynamic VBO as they have to be updated per frame, and a single set of texture coordinates in a static VBO as these are invariant over time. The driver should be able to pick the best place for each VBO according to their uses.

The problem I find is when I come to render the geometry.

The way I have understood the spec, when you call glBindBufferARB and then vertex array pointer functions, the driver will sort out the correct address of the array data according to which VBO is currently bound.

So my render function binds the static VBO
and calls glTexCoordPointer, then binds the dynamic VBO and calls glVertexPointer and glNormalPointer. Finally, glDrawElements is called.

The result is, at least, partially (i.e. not all vertices) scrambled vertex positions and screwed texture coordinates.

If I remove the static VBO, the rendered result is as expected.

So my question is have I misinterpreted the “scope” of glBindBufferARB? Does it just affect, say, vertex array pointer functions while bound, or does its affects go as far as glDrawElements (and the like)?

If the latter, how does anyone else handle a combination of static and dynamic vertex data in the same geometry?



glBindBufferARB does not affect glDrawElements (and the like) expect if your index array is stored in a vertex buffer, using GL_ELEMENT_ARRAY_BUFFER_ARB.

The gl*Pointer commands specifies a pointer for the buffer that is currently bound by glBindBufferARB. So, yes you can have vertex+normal data on a dynamic buffer, and color data on (another) static buffer. This flexibility is one of the goals of the extension.

Have you (or anyone in fact) had any experience with this working? This will help for me to determine if it’s an error in my code or not.



I could make working multiple vertex buffer objects for a single glDrawElements call, but all buffers are static. I haven’t tried with dynamic+static buffers (yet).

So is your render function something along the lines of, say,

glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, indexBuffer);

glBindBufferARB( GL_ARRAY_BUFFER_ARB, staticBuffer1);
glPointer( … );
Pointer( … );

glPointer( … );
Pointer( … );

glDrawElements( … );

as that is what I have, more or less.

Are you multiple static buffers for single array type data, e.g. normals only, or colors only?

I am using interleaved vertex data, so in the dynamic VBO:

position, normal, position, normal, etc.



That looks right. I’ve implemented something like this, and it worked fine.

Do you have a test app that fails?

Well, turned out it was my problem throughout

The partially scrambled vertex positions was due to bad initialization data. This did not occur in future frames when position and normal data was updated.

And the screwed texture coordinates was me, binding the correct VBOs in the render function, but then in the next frame when I morphed the positions and normals, I’d forgotten to bind the correct VBO to do this.

So, it all works. Great!