• Advertisement
Sign in to follow this  

drawing circle

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

Hello, I was trying to draw a circle in my program but got bizarre polygon. What I'm doing wrong and is there any other method to render a circle? Here's the code: glBegin(GL_LINE_LOOP); for (i = 0; i < 360; i++) { angle = PI*i/180; glVertex3f(cos(angle), sin(angle),0); } glEnd(); thank you!

Share this post


Link to post
Share on other sites
Advertisement
Hi,

what happens is the following:
i < 180 ==> i/180 = 0 (integer devision)
i < 360 ==> i/180 = 1

so try the follwoing:

glBegin(GL_LINE_LOOP);
for (i = 0; i < 360; i++)
{
angle = PI*i/180.0;
glVertex3f(cos(angle), sin(angle),0);
}
glEnd();


Share this post


Link to post
Share on other sites
That works for me:

float angle = 0.0f;
glBegin(GL_LINE_LOOP);
for (int i = 0; i < 360; i++)
{
angle = PI*i/180.0;
glVertex3f(cos(angle), sin(angle),0);
}
glEnd();



Could you post a screenshot of what you get? Maybe the error lies elsewhere.

Share this post


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

  • Advertisement