glDrawElements

The following two methods produce the same results. I am working through some Game Institute courses and I am trying to figure out a few specific details about these different methods.

First Method 1 once rendered has the mesh rotating at a very slow rate where mesh 2 rotates the mesh much faster. I don’t really understand why anything within this code would effect a rotating speed. Can anyone offer advice why?

Second, I don’t understand why in method 2 there is a need to pass g_TriangleCount3 in the
glDrawElements(GL_TRIANGLES,g_TriangleCount
3,GL_UNSIGNED_SHORT,
function call. The second param in the glDrawElements function needs to be the number of triangles so why is there a need to multiply the triangles by 3. Multiplying by 3 returns the number of vertex’s right?

Render Mesh 1
glBegin(GL_TRIANGLES);
for(TriangleNum=0; TriangleNum{
for (int VertexNum = 0; VertexNum < g_VertexCount; VertexNum++)
{
glVertex3f(g_pVertices[VertexNum].x,g_pVertices
[VertexNum].y,g_pVertices[VertexNum].z);
}
}
glEnd();

Render Mesh 2
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, g_pVertices);
glDrawElements(GL_TRIANGLES,g_TriangleCount*3,GL_UNSIGNED_SHORT, g_pFaceIndices);
glDisableClientState(GL_VERTEX_ARRAY);

The second method uses vertex arrays. These are much faster than the immediate mode used in the first piece of code. I assume that the rotation is tied to the framerate not governed by a timer. This means that the faster framerate caused by the use of vertex arrays leads to faster rotation

As for the second question, draw elements takes the number of vertices as an input, not the number of triangles. GL_TRIANGLES just tells the computer to treat the list of vertices as triangles

[This message has been edited by chowe6685 (edited 06-07-2003).]