glDrawElements

Hello, i dont really get what’s possible with glDrawElements.
I want to read whats happening in glDrawElements.
When i call this function like
glDrawElements(GLenum mode,GLsizei count,GLenum type,const GLvoid *indices)
{
//code here
}

Then what does “count” contain? Is it possible to check if an object is drawn by a number.
So for example something like this.

if(count == 1200)
{
//the cube is drawn
}

Take a good opengl programming book or at least see good tutorials about gl, check nehe on a search engine for example.

I already checked that site, and it definitly doesnt answer my question in the tutorials.

I belive count indicates the no of elements

for example consider the following example
Following is array which describing the indices of a model.
Here we want to render a model using triangle data,Since triangle contains 3 vertices, we refer the count as 3.

static GLint Indices[] = { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23, 24, 25, 26, 24, 26, 27, 28, 29, 30, 31, 32, 33,34, 35, 36, 37, 38, 39, 40, 41, 42, 40, 42, 43};
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[0]);

Suppose if we want to render as polygon, which is represneted by 4 vertices, we will refer count as 4.

example
glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_BYTE, &Indices[0]);

Hope this helps you

Rajesh.R
IRIS,CAIR
Bangalore
rajeshr@cair.res.in

Originally posted by <Rajesh>:
[b]I belive count indicates the no of elements

for example consider the following example
Following is array which describing the indices of a model.
Here we want to render a model using triangle data,Since triangle contains 3 vertices, we refer the count as 3.

static GLint Indices = { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23, 24, 25, 26, 24, 26, 27, 28, 29, 30, 31, 32, 33,34, 35, 36, 37, 38, 39, 40, 41, 42, 40, 42, 43};
glDrawElements(GL_TRIANGLES, 3, GL_UNSIGNED_INT, &Indices[0]);

Suppose if we want to render as polygon, which is represneted by 4 vertices, we will refer count as 4.

example
glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_BYTE, &Indices[0]);

Hope this helps you

Rajesh.R
IRIS,CAIR
Bangalore
rajeshr@cair.res.in[/b]
OpenGL already knows how many vertices there are in a triangle; three, so you don’t have to say it. What you haven’t told OpenGL though is how large the index array is, you’ve only provided a pointer to the first element, but made no indication of where it ends.

count is the number of indices in the index array. In that example, count should be 60, as there are 60 indices (if I counted them correct).