View Full Version : Drawing from two different VBOs at once?
10-23-2007, 08:46 AM
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.
Nick's a Novice
10-23-2007, 10:23 AM
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.
10-23-2007, 11:39 AM
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?
10-23-2007, 04:37 PM
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.