in my little engine i store and display my models like this:
i have an array of vertices (x,y,z positions and u,v texture coordinates), one for vertex normals ( x,y,z direction) and one for polygons (3 indices for vertices and 3 indices for normals each).
this works fine if i use the standard code to draw:
glBegin(GL_TRIANGLES);
loop through polygons
{
loop from 0 to 3
{
glNormal3f(normal@current normal index);
glTexCoord2f(texcoord@current vertex index);
glVertex3f(vertex@current vertex index);
}
glEnd();
to improve speed i now want to use vertex arrays. i got it working for vertex data and vertex indices so far.
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, Vertices);
glDrawElements(GL_TRIANGLES, NumIndices, GL_UNSIGNED_INT, Indices);
glDisableClientState(GL_VERTEX_ARRAY);
but i’m having trouble to make my vertex normals and texture coordinates work:
question #1: do the indices (the last parameter of glDrawElements() only apply to the vertex array or also to the texture coordinates and the vertex normals array, e.g. if the current index is 5, will it only use for the 5th element of the vertices array, or also the 5th elements of the texture coordinates and normals array?
#2: if they apply to all arrays, then i have to make sure that every array has the same size and order, right? so i’ll probably have to duplicate some data, as in most cases you have less normals than vertices, but more texture coordinates than vertices etc. is this correct?
#3: so if i end up with more data than without using vertex arrays, will it really speed up my app or even slow it down?
#4: do you know of a 3d format that saves its data in a way that i can easily use it to fill my arrays, i.e. that stores vertices, uv coords and normals in equaliy sized arrays and needs only one set of indices?
sry if these are stupid questions, i’m still new to this stuff and the tutorials i read always just use very simple models like cubes to demonstrate how vertex arrays work
thx in advance!