PDA

View Full Version : GL_TRIANGLE_FAN with glDrawElements

guju
06-25-2002, 07:37 AM
Hi!
I have splittet my quads into four tris. I stored the vertexindices an an array like:
v0,v1,v2,v0,v2,v3,v0,v3,v4,v0,v4,v1
Then i call:
But no error occurs and i can not see anything!!!???!
Thanks

Robbo
06-25-2002, 07:56 AM
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'.

LordKronos
06-25-2002, 08:52 AM
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.

guju
06-25-2002, 11:01 AM
Ok,LordLornos. I have now defined center, corner1,corner2,corner3,corner4. Then i call
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??
Thanks
Juergen

Zeno
06-25-2002, 11:54 AM
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).]

LordKronos
06-25-2002, 12:56 PM
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.