OpenGL- Fill in Circle

Started by
2 comments, last by geowar 12 years, 10 months ago
I was just wondering, how do I fill in a circle with a color? Here's my code:

glBegin(GL_LINE_LOOP);
    for(int i =0;i<num_lines;i++)
    {    
    angle = i*2*3.14159/num_lines;
    glVertex2f(cos(angle),sin(angle));
    }
glEnd();

It's probably very easy. Thanks.
Advertisement
GL_LINE_LOOP is a loop made up of line segments. You probably don't want line segments, you want a polygon. So try GL_POLYGON. Keep in mind that under normal culling mode, the vertices have to be in counterclockwise order.
Thanks, it worked.
[color=#333333][font=Verdana, Arial, Tahoma, Calibri, Geneva, sans-serif][size=2]If it's a filled circle:

glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);
glPointSize(radius);
glPoint(x, y, z);[/font]
-- Enjoy,George Warner,Schizophrenic Optimization ScientistApple Developer Technical Support (DTS)

This topic is closed to new replies.

Advertisement