 # Triangle fans problem???

I am working on creating a routine that will create a 3D object based on the number of sides. 3 sides = pyramid, 4 sides = cube, etc.

I am trying to use the TRIANGLE_FAN option to create a side of the 3D object.

glBegin(GL_TRIANGLE_FAN)
glColor3f( 1.0f, 0.0f, 1.0f )
glVertex3f( 0.0f, 0.0f, 0.0f)
for(i=sides; i < sides; i++)
{
glVertex3f(mx, my, 0.0f)
}
glEnd()

The thing is after the routine run’s there is nothing drawn… Is there something missing? in order to use Triangle_fan?

Maybe there are just typos in the code you’ve written here, but I guess the loop is at least very strange. It should better look like this, if I understand right what you want to do:

for(i=0; i<sides; i++) {
glVertex2f(mx, my);
}

Flash

I guess that it was the long way around but I wanted to use degree’s but maybe to simplify that routine I should just stick to rad.
Yea, I believe you got the idea of what I am trying ot do.
One other question is a triangle fan need’s a min. of 3 points, to create one triangle?

Originally posted by flashp:
[b]Maybe there are just typos in the code you’ve written here, but I guess the loop is at least very strange. It should better look like this, if I understand right what you want to do:

for(i=0; i<sides; i++) {
glVertex2f(mx, my);
}

Flash[/b]

Three points for the first triangle and one point for every triangle after that. The initial point (ex. 0) and the previous point (n-1) are used with the last point (n)
to create the next tri in the fan. Here’s a cheezy ascii diagram

1 2 3
\ | /|
\ | / |
0 __4
\ |
\ |
5

0 is the initial point, 4 is n-1, and 5 is n. Clear as mud?? 