# Thread: How 2 draw a circle

1. ## How 2 draw a circle

Hello,
I am doing my project now...wat i need 2 do now is wanna drawing a simple circle.....who can tell me how should i draw a circle with a GL_LINE_LOOP or GL_POLYGON...??

Thank you.

2. ## Re: How 2 draw a circle

Hi !

With GL_LINE_LOOP you will get a circle, with GL_POLYGON you break down the "circle" into triangles, so if you just want a circle, use GL_LINE_LOOP if you intend to fill it with color or texture then use GL_POLYGON (a disk).

Mikael

3. ## Re: How 2 draw a circle

play with this:

Code :
```GLfloat r = 1.;

glBegin(GL_LINE_LOOP);

for(float phi = 0; phi <= 2*M_PI; phi += M_PI/10.)
glVertex3f(r*cos(phi), r*sin(phi), 0.);

glEnd();```

4. ## Re: How 2 draw a circle

Originally posted by GreetingsFromMunich:
play with this:

Code :
```GLfloat r = 1.;

glBegin(GL_LINE_LOOP);

for(float phi = 0; phi <= 2*M_PI; phi += M_PI/10.)
glVertex3f(r*cos(phi), r*sin(phi), 0.);

glEnd();```
hello,I am also a beginner,I am thinking if do like that,would i gain a circle not filled?
3Q

5. ## Re: How 2 draw a circle

Yes, you will get lines, that's the idea with GL_LINE_LOOP, if you replace GL_LINE_LOOP with GL_POLYGON you will get a filled circle instead (if you have setup the correct polygon mode).

Mikael

6. ## Re: How 2 draw a circle

for a filled circle i'd rather use a triangle fan than a polygon:

Code :
```GLfloat r = 1.;

glBegin(GL_TRIANGLE_FAN);

glVertex3f(0., 0., 0.);

for(float phi = 0; phi <= 2*M_PI; phi += M_PI/10.)
glVertex3f(r*cos(phi), r*sin(phi), 0.);

glEnd();```
the first vertex defines the center, the vertices in the for-loop lie on the perimeter

7. ## Re: How 2 draw a circle

Originally posted by mikael_aronsson:
Yes, you will get lines, that's the idea with GL_LINE_LOOP, if you replace GL_LINE_LOOP with GL_POLYGON you will get a filled circle instead (if you have setup the correct polygon mode).

Mikael
Thank you very much

#### Posting Permissions

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