GL_TRIANGLE_FAN with glDrawElements

I have splittet my quads into four tris. I stored the vertexindices an an array like:
Then i call:
glDrawElements (GL_TRIANGLE_FAN, numQuads*4, GL_UNSIGNED_INT, elements_texture_tri);
But no error occurs and i can not see anything!!!???!

For a quad? firstly, you shouldn’t be using fans at all. Secondly, for a quad, the fan indices (assuming v0 is bottom left and its clockwise) : v0 v1 v2 v3. openGL knows that because its a fan, the first vertex is the `apex’.

No, he’s saying he put a vertex in the center of the quad, and split it into 4 quads along the diagonals

The problem is that for a triangle fan, you only specify each vertex once. First you specify the first 2 verticies, and for every vertex you add after that it draws a triangle using 3 points (first vertex, previous vertex, current vertex). Thus to draw your quad you want to specify the verticies in this order:
center, corner 1, corner 2, corner 3, corner 4
where corners 1 through 4 are in clockwise order.

Ok,LordLornos. I have now defined center, corner1,corner2,corner3,corner4. Then i call
glDrawElements (GL_TRIANGLE_FAN, numQuads*4, GL_UNSIGNED_INT, elements_texture_tri);
But i see strange results. For the number of vertices i multiplied the number of quads by 4. Should i only give it the number of vertices, or what is it for GL_TRIANGLE_FAN??

Yes, you should only give the number of vertices. In your case, replace numQuads * 4 with 5.

– Zeno

[This message has been edited by Zeno (edited 06-25-2002).]

I think you made another mistake. You said you used number of quads * 4. I dont think you realize that you can only draw one fan at a time (one per call).

If your “fanned” quads all lie adjacent to one another (ie: in a grid) you can probably achieve much better results using triangle strips or indexed triangle strips. If not, you might still be better of going with an indexed triangle list rather than a triangle fan.