Indexed arrays

Hi, I was wondering if you can have separate indexed arrays for colour, uv coordinates and points. atm the only way I know of doing indexed arrays is something like

struct
{
float point[3];
float colour[4];
float uv[2];
}

glVertexPointer( … );
glColorPointer( … );
glTexturePointer( … );

glDrawElements( … );

If all the texture coords and colours were the same, then drawing a cube would only need 6 vertices. However, atm my cube has different uv mappings on each face and I get a load of unecessary elements. Is there way I can have separate arrays for colour, uv and vertex?

No, multiple index arrays is not supported in OpenGL.

Note that this feature is proposed for integration in the forthcoming OpenGL 2.0.

I’m very new to opengl and just wanted to get something straight. I was trying to build an OBJ Model Loader, I built most of it and it worked fine for constructing triangle based models out of the enabling just the VERTEX_ARRAY…

…but my problem, is that I am a little confused when it comes to the lines starting with “f” in the obj file. I know there can be different combinations such as v or v/vt or v/vt/vn… but, I setup glEnableClientState for vertex array and texture array and normal array and then setup glVertexPointer, glNormalPointer and glTexCoordPointer linking those to the arrays of lines starting either with v, vn or vt.

The final part to draw the model using the loaded data confused me: glDrawElements(), and basically I can only feed it one array of data (vetice, texture, or normal) due to the fact that they do not all correlate in order to build the model correctly (e.g f 1/1/1 2/2/3 3/3/4). This means that if glDrawElements() is based on the vertice array it will try and use the wrong normals for those vertices. Do you understand what I mean?? Hope you do. As I’m really confused at the moment and hope some of you can help me out of my situation.

Regards

Antony Ribot

So, did I make any sense at all?

Even a little bit of feedback would be very grateful!

Thanks

ribot

Originally posted by ribot:
[b]I’m very new to opengl and just wanted to get something straight. I was trying to build an OBJ Model Loader, I built most of it and it worked fine for constructing triangle based models out of the enabling just the VERTEX_ARRAY…

…but my problem, is that I am a little confused when it comes to the lines starting with “f” in the obj file. I know there can be different combinations such as v or v/vt or v/vt/vn… but, I setup glEnableClientState for vertex array and texture array and normal array and then setup glVertexPointer, glNormalPointer and glTexCoordPointer linking those to the arrays of lines starting either with v, vn or vt.

The final part to draw the model using the loaded data confused me: glDrawElements(), and basically I can only feed it one array of data (vetice, texture, or normal) due to the fact that they do not all correlate in order to build the model correctly (e.g f 1/1/1 2/2/3 3/3/4). This means that if glDrawElements() is based on the vertice array it will try and use the wrong normals for those vertices. Do you understand what I mean?? Hope you do. As I’m really confused at the moment and hope some of you can help me out of my situation.

Regards

Antony Ribot[/b]