# Thread: drawing a smooth circle

1. ## drawing a smooth circle

hi. I am new to openGL and would like to draw a smooth circle..
Can anyone hint me ?

Should I use gl.glBegin(GL.GL_LINE_STRIP) and some sine, cosin in it??

thanks

2. ## Re: drawing a smooth circle

Something like this..

Code :
```const float DEG2RAD = 3.14159/180;

{
glBegin(GL_LINE_LOOP);

for (int i=0; i &amp;lt; 360; i++)
{
}

glEnd();
}```

Do remember that Google is your friend.. You could have found this with less typing and got a quicker answer with a Google search.

3. ## Re: drawing a smooth circle

Other solution can be to fake a circle by using gluDisk() and set parameters accordingly. i.e set inner radius equal to outer radius.

Another method can be to go for subdivision curves , midpoint , catmull clark if you want to go for higher precision.

Or you can draw it using NURBS.

You can not get a perfect circle though.

4. ## Re: drawing a smooth circle

And if you want it to be really really smooth, check out GL_LINE_SMOOTH (hint: enable blending).

5. ## Re: drawing a smooth circle

thank you very much .
I have done it.

gl.glBegin(GL.GL_LINE_LOOP);
for(int i =0; i <= 300; i++){
double angle = 2 * Math.PI * i / 300;
double x = Math.cos(angle);
double y = Math.sin(angle);
gl.glVertex2d(x,y);
}
gl.glEnd();

6. ## Re: drawing a smooth circle

Check out this site: http://slabode.exofire.net/circle_draw.shtml

The code there draws circles and arcs without using sine or cosine and is very fast.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•