PDA

View Full Version : vertex array problem



Asshen Shugar
04-12-2001, 01:47 AM
Houston I have a problem ;-)

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

glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);

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
arrays?)

Thank you very very much !!!

Asshen Shugar
valheruasu@hotmail.com

Deiussum
04-12-2001, 04:38 AM
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.

Asshen Shugar
04-12-2001, 04:55 AM
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

Asshen