onorinbejasus
01-19-2010, 08:14 PM
I am attempting to draw a circle using the gl_Triangle_Fan. Here is what I have thus far:
int i;
int triangles = 20; // number of triangles
float twoPi = 2.0f * 3.14159f;
glBegin(GL_TRIANGLE_FAN);
glVertex2f(my_x,my_y); // origin
for(i = 0; i <= triangles; i++) {
glVertex2f((radius * cos(i * twoPi / triangles)),
(radius * sin(i * twoPi / triangles)));
}
glEnd();
my_x and my_y are the positions of the mouse.
When the program begins, there is a semicircle in the bottom left-hand corner of the screen, but when I click a new location, the circle becomes a massive line that enfulges the screen. Any help would be greatly appreciated
int i;
int triangles = 20; // number of triangles
float twoPi = 2.0f * 3.14159f;
glBegin(GL_TRIANGLE_FAN);
glVertex2f(my_x,my_y); // origin
for(i = 0; i <= triangles; i++) {
glVertex2f((radius * cos(i * twoPi / triangles)),
(radius * sin(i * twoPi / triangles)));
}
glEnd();
my_x and my_y are the positions of the mouse.
When the program begins, there is a semicircle in the bottom left-hand corner of the screen, but when I click a new location, the circle becomes a massive line that enfulges the screen. Any help would be greatly appreciated