The following code works and I get a triangle
static GLfloat vtx[] =
{
-10.0f, 0.0f, -50.0f,
10.0f, 0.0f, -50.0f,
0.0f, 10.0f, -50.0f
};
glBegin(GL_TRIANGLES);
glVertex3f(vtx[0], vtx[1], vtx[2]);
glVertex3f(vtx[3], vtx[4], vtx[5]);
glVertex3f(vtx[6], vtx[7], vtx[8]);
glEnd();
However when I try to use glDrawElements
static GLuint idx[] = { 0, 1, 2 };
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, &vtx[0]);
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &idx[0]);
glDisableClientState(GL_VERTEX_ARRAY);
Or replcae the glDrawElements with glDrawArrays
glDrawArrays(GL_TRIANGLES, 0, 3);
I get nothing…Given that the first code segment works what is it I’m doing wrong? (or even just suggestions).
I’ve tried clockwise/aniti-clockwise indices, but since the first code segment works I didn’t think that could be the problem.
Thing is I’ve got another part of the code all working using glDrawArrays and glDrawElements using VBOs so I’m at a loss as to why this simpler code doesn’t work.
Cheers,
STU!