# The Industry's Foundation for High Performance Graphics

1. ## Drawing a circle

I am attempting to draw a circle using the gl_Triangle_Fan. Here is what I have thus far:

Code :
```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

2. ## Re: Drawing a circle

The whys and wherefores of what happens when you click your mouse can't really be determined from the code you've posted. I suspect it's something to do with the GLUT screen refresh as it sounds like that kind of problem.

Try this web page for what you want :
http://en.wikibooks.org/wiki/OpenGL_...sics/2DObjects

3. ## Re: Drawing a circle

Originally Posted by onorinbejasus
Code :
```const unsigned int triangles = 20; // number of triangles
const float twoPi = 2.0f * 3.14159f;
glBegin(GL_TRIANGLE_FAN);
glVertex2f(my_x,my_y); // origin
float delta = twoPi / triangles;
for(unsigned int i = 0; i <= triangles; i++)