Drawing from two different VBOs at once?

I’d like to read color from one VBO and vertex position from another. Is this possible?

It would require the glColorPointer (or glVertexPointer) function to retain it’s pointer internally after a buffer is unbound, which doesn’t seem to be the case based on trying to use a non-VBO VA alongside a VBO.

With VBOs i was told this is not only possible, but completely legal. Though i have never actually tried it myself. But there is an example, in the spec, if i remember correctly.


	glBindBufferARB( GL_ARRAY_BUFFER_ARB, vertexVBO_ );
	glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );		// Set The Vertex Pointer To The Vertex VBO
	glEnableClientState( GL_VERTEX_ARRAY );
	glBindBufferARB( GL_ARRAY_BUFFER_ARB, colorVBO_ );
	glColorPointer( 4, GL_FLOAT, 0, (char *) NULL );		// Set The Color Pointer To The Color VBO
	glEnableClientState( GL_COLOR_ARRAY );
	glDrawArrays(GL_TRIANGLE_STRIP, 0, numVert);
	glDisableClientState( GL_VERTEX_ARRAY );
	glDisableClientState( GL_COLOR_ARRAY );

I’m not entirely sure if this is what you are looking for but this works for me.

Huh, I never read specs fully. I just presumed this wasn’t possible.

Can anyone say if and how this impacts performance? Are you likely to get worse performance than from non-interlaved attributes in the same VBO?

I generally render this way - by storing each attribute in its own VBO. I haven’t noticed any performance hits with my computer and GPU.