glDrawElements confusion


just a short question about glDrawElements.

I want to render an array of triangles. using a unsigned int* buffer where the indices are stored in.

so, I have an array of vertices, glVertexPointer it and then I’ll draw it with glDrawElements.

is it like:
unsigned int* facebuffer;

glDrawElements(GL_TRIANGLES, number_of_faces, GL_UNSIGNED_INT, facebuffer)

or is it:

glDrawElements(GL_TRIANGLES, number_of_faces*3, GL_UNSIGNED_INT, facebuffer)



thanks for help!

Hi !

It’s the number of elements to render, not the number of vertices, look at it as if you where calling glArrayElement() in a loop where element count is the number of times to run the loop.


yeah. but is the number of elements the number of triangles I have or the number of indices in total? (for a triangle: number of triangles * 3)

It’s the number of indices in total.