Jump to content
  • Advertisement
Sign in to follow this  

OpenGL- Fill in Circle

This topic is 2526 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

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);[/font]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!