DrawElements and sharing indices

Hi,

I’ve got a model with vertex, normal and texture coordinates data and I want to draw this using DrawElemets. The problem is that each vertex has diffrent normal and texture coordinate.
DrawElements calls every enabled array element with given index. I want to call vertex array element with vertex index, normal array element with normal index and texcoords array element with texcoord index, respectively. Is it possible using arrays? I tried with InterleavedArrays but it gives no success. For now I’ve got a code for drawing (face arrays includes indices):

// this is only pseudo code, cutted for better reading
glBegin( GL_TRIANGLES );
for( int j = 0; j < numFaces; j++ )
{

glTexCoord2fv( texCoords[ texcoords_faces[j] ] );
glNormal3fv( normals[ normal_faces[j] ] );
glVertex3fv( vertices[ vertices_faces[j] ] );
}
glEnd();

Thanks for help

That is not possible. There’s only one index which is used for all attributes. So duplicate vertices that have different normals/texcoords.

Originally posted by glYaro:

DrawElements calls every enabled array element with given index.

That is how it is and there is no way around it. You just have to make all your arrays of the same size. This means that you have to dublicate vertices if they have more than one normal or texcoord. But glDrawElements will likely draw faster than immediate mode and it is very easy to implement vbo afterwards.

hih

I supposed that. Thanks anyway