View Full Version : multiple objects with vertex arrays
09-17-2002, 10:23 PM
How can i render multiple objects using Vertex arrays?
I'm specifying an array calling
glInterleavedarrays(), so ogl has the vertex data. now how do i declare multiple objects...? if i just call glInterleavedarrays() again opengl will overwrite it, won't it?
and then how can I draw them seperately?
glDrawElements lets me draw my vertex array, but how can i manage multiple arrays for multiple objects?
09-18-2002, 04:27 AM
There are a few different possibilities.
1) Put all your vertices into one array, then bind that array with glInterleavedArrays. Then for each object keep a list of indices, and draw each object using glDrawElements with the appropriate list of indices.
2) For each object, keep a separate list of vertices and indices. Then for each object, first use glInterleavedArrays to bind the appropriate array, and then glDrawElements to draw the object.
3) For each object, keep a separate list of vertices. For each object you draw, bind the array with glInterleavedArrays, and draw the object with glDrawArrays.
4) Keep a single list of vertices where vertices for each object are grouped together. (e.g. all vertices for the first object are at the beginning of the array, all vertices for the last object are at the end of the array.) When drawing the object, use glDrawArrays, and specify the appropriate index for the start of the object, and the appropriate count for the number of vertices used in that object.
Personally, I tend to prefer option 2.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.