Sign in to follow this  
Vladk10000

OpenGL- Fill in Circle

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[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);[/size][/font][/color]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this