Jump to content
  • Advertisement
Sign in to follow this  
arczev

drawing circle

This topic is 4114 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
×

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!