PDA

View Full Version : Multiple Vertex Arrays...



Richelieu
09-17-2000, 08:06 AM
Hi,
I've been reading for the last 2 weeks or so, ran into a question... (no, I'm not trying to make an "engine". http://www.opengl.org/discussion_boards/ubb/smile.gif)

I have created a vertex array, and been able to render it. No sweat. BUT, how would I go about doing multiple vertex arrays?

One would go like:
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &torusVerts);
glDrawElements(GL_TRIANGLES, 1728, GL_UNSIGNED_INT, torusFaces);
glDisableClientState(whatever);

Could I then make a new vertex pointer to a different array, and then immediately render another array?

Or would I do it all within the enable/disable pair?

If I do multiple vertex arrays inside the pair, how do they know which two arrays (one for vertices, one for faces) coorespond to each other?

Thanks.

DFrey
09-17-2000, 09:36 AM
You can use any number of vertex arrays. And you would want to do it all within the glEnableClientState/glDisableClientState pair just to minimize function calls and client state changes. You don't show it in your example, but I'll mention it anyway, if you happen to be using compiled vertex arrays, then you must unlock the vertex array before changing the vertex pointer (and then relock the array if necessary).


[This message has been edited by DFrey (edited 09-17-2000).]

Richelieu
09-17-2000, 05:51 PM
Originally posted by DFrey:
if you happen to be using compiled vertex arrays, then you must unlock the vertex array before changing the vertex pointer (and then relock the array if necessary).


How and What is unlocking the vertex array? I have the OpenGL Super Bible, along with several examples, and I haven't seen any examples of using more than one Vertex Array at once.. hence, no idea that lock/unlocking would be accomplished....

DFrey
09-17-2000, 06:10 PM
Don't worry about locking or unlocking the array if you aren't using compiled vertex arrays. And from your example you aren't.
For the code you have shown, you can change the vertex array pointer anytime within the glEnableClientState/glDisableClientState pair.