View Full Version : A question about Indexed Arrays

08-01-2001, 04:11 AM
I want to use in my program indexed arrays. Is it possible to use indexed arrays for texture coordinates and normals? In OpenGL documentation it says to use glDrawElements but in this function I can only specify the vertex index array.the other two indexes with which function can be specified? Or must i use non-indexed array for texturecoords and normal even though i use indexed vertex arrays?

Thanx in advance for the help


08-01-2001, 04:41 AM
Of course it's possible.
Your program should look like
glVertexPointer (...
glNormalPointer (...
glDrawElements (...
But be careful, you must have the same number of vertices, normals, texcoords... So if you want to have more than one normal for one vertex (For example if you want to draw a non-smooth object, like a cube), you'll have to duplicate your vertex. Your vertex array will contain several times the same vertex, so one might say that it's memory-wasting, but it's the only solution that I know.

08-01-2001, 11:11 AM
The problem is that i get my data from a VRML file. In this format it gives you 3 arrays (vertex,normal,texcoord) plus 3 indexed arrays for these. So it is quite difficult to re-arrange the arrays to work with only one index. If a vertex has different combinations of normal and texcoordinates then the memmory usage will exceed that of the non indexed arrays.

Actually my first implementation was with display lists.Does it worth the trouble to make it work with indexed arrays?

08-01-2001, 11:47 PM
Dude, it's only worth the trouble if you have a LOT of geometry. Otherwise you are wasting youre time. In other words, don't go make a indexed vertex array for a couple of cubes. There is a vertex array specifically for texture coordinates. You have one for a normal vertex array, one for indexed vertex array, on for youre normals, and there's one for tex coordinates. There's probably more, can't remember right now. Consult a manual... http://www.opengl.org/discussion_boards/ubb/smile.gif