Sign in to follow this  

Opengl Draw Circle

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

This topic is 3592 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.

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