Jump to content
  • Advertisement
Sign in to follow this  
Bobalandi

Opengl Draw Circle

This topic is 3807 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

Hi, I've been trying to draw a circle at specific coordinates (x,y) with a radius of 5, so I have this code:
    glBegin(GL_LINE_LOOP);
        glColor3f(0.0,1.0,0.0); 
        for (int i=0; i < 360; i++)
        {
            float degInRad = i*DEG2RAD;
            glVertex3f(cos(degInRad)*5,sin(degInRad)*5,0.0f);
        }
    glEnd();

But it doesn't work at all, and I'm not sure why, also, DEG2RAD is just const float DEG2RAD = 3.14159/180; EIDT: I got it to show, but it only shows 1/4 of it in the bottom left corner, at the point (0,0) Thanks, I'd appreciate the help.

Share this post


Link to post
Share on other sites
Advertisement
How did you fix it? It's always frustrating when you come to someone's post through google and they say they fixed it, but never say how!

I probably wouldn't be rendering 360 segments of a line loop. As few as 20 will look smooth and be a lot more efficient. There may be a glu function to do this (I know there is one for spheres), but if not you can look at the sphere function for inspiration.

Share this post


Link to post
Share on other sites
Quote:
Original post by jonahrowley
How did you fix it?

The circle is positioned at the origin in the XY-plane, I suspect the OP simply was not 'looking' at the circle.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!