vertex array problem

Houston I have a problem :wink:

I’m using vertex arrays for rendering, like this :


glTexCoordPointer(2, GL_FLOAT, 0, texcoord);
glNormalPointer(GL_FLOAT, 0, normals);
glVertexPointer(3, GL_FLOAT, 0, vertices);

glDrawElements(GL_TRIANGLES, icol*3, GL_UNSIGNED_INT, vertexindicies);

The indicies of my vertices, texture coordinates and normals are in
different arrays !!!
vertexindicies[][], texcoordindicies[][] and normalindicies[][] …
So it is obvious that the texture mapping and the normals are not being
rendered correctly !

Is there any way to add the normal and texcoord indicies arrays to
glDrawElements, so that it would render everything correctly ??? Or should I
switch to interleaved arrays (if yes, how do I add indicies to interleaved

Thank you very very much !!!

Asshen Shugar

You will need to arrange your vertex/texcoord/normal data so that the indices for the texture coordinates, normals, and vertices all match up. If you are trying to do something such as have different texture coordinates or normals for the same vertex, you will have to have multiple copies of that vertex in the vertex array. If you are using face normals, you will have to have 3 copies of those per triangle, one for each vertex.

I feared as much, lol…
So I just have to convert the normal and texcoord arrays so that they use the same indexes as the vertex array ?
damn, that will be some work…

Lol, thanks for your help