Data Structures and Vertex Arrays

Greetings people.

I currently trying to rewrite my drawing routines to make them faster and resemble my data structures more accurately. (I don’t mind changing my data structures to achieve this)

I’m currently using immediate mode to draw anything that hasn’t been compiled into a display list. But immediate mode has become too clunky and I want to use vertex arrays instead.

One thing that’s been bothering me has been the issue of indexed vertex arrays. When using indecies, is it only the “vertex” portion of the data that gets indexed or ALL data (tex coords, normals etc). I ask because while I currently store my data using indecies, most vertecies have multiple normal vectors depending on the polygon they’re currently assocated with. So if normals are indexed, it’s going to screw everything up…

And while on that point. Is there a significant advantage to using indexed arrays over non-indexed arrays? Other than the obvious memory savings.

Addition: Or am I missing something really obvious?

Anything you defined an array for will be
indexed using the same index. If you have a
vertex with multiple normals for difference
faces, you have to duplicate the vertex
coordinates (because it’s really two different
vertexes, they are lit different).

In most meshes, smoothing is the normal case
so this isn’t a very big penalty, and probably
one of the reasons the API looks like it does.
Another would be that a single index makes
caching transformed data much easier (yeah,
the folks at SGI figured these things out
ten years ago, before they became the folks
at nVidia :slight_smile:

I can say how I’m doing my rendering :

I have an object class that is derived by all mine shapes.

The objects class stores data in this way

Vertex3* vertexes;
Vertex3* normals;
rgb_a* colors;
int numvertex;
Vertex2* uvcoords;
int numuvcoords;
GLuint* triindices;
GLuint numindices;

i render everything calling glDrawElements, and it’s also quite easy to deform/transform objects

The derived class has also some “modifiers” methods that are meant to modify the vertex data (for example : a ripple or bones)

rIO.SK [](