Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

madmax22e

algortims for making circles in opengl

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

is there a way to make a circle out of triangles in opengl. i figure if the vertices are close enough it could look like a circle. any help would be appreciated

Share this post


Link to post
Share on other sites
Advertisement
use GL_TRIANGLE FAN. start with a center point, and then plot however many points you want in r*cos(angle) and r*sin(angle) fashion, where those two cos/sin statements are the x,y coords, and r is the radius.

Share this post


Link to post
Share on other sites
Im not sure exactly what you mean by that, could you maybe show the a sample of actual code that would do all that you said. thanks

Share this post


Link to post
Share on other sites
sure.
(this is pseudocode, cuz i'm not sure if it'll compile, but i'll try to make it almost code.)

#define DTR //degrees to radians (2pi/360)

GLfloat center[2] = {30,30};
GLfloat radius = 10.0;

glBegin(GL_TRIANGLE_FAN);
glVertex2d(center[0], center[1]);
for (int angle = 0; angle <=360; angle ++)
{
glVertex2d(center[0] + (radius * cos(angle * DTR)),
center[1] + (radius * sin(angle * DTR));
}

glEnd();


// this code should render a circle with a refinement of
// every degree out of 360. i don't think you necessarily
// need a refinement of 360 degrees, but if not, just
//change the increment value of angle by a factor of 360.

a2k

Edited by - a2k on 4/19/00 8:06:26 PM

Edited by - a2k on 4/19/00 8:12:08 PM

Edited by - a2k on 4/19/00 8:13:38 PM

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Well, there is that gelDrawPerfectAss() function in OpenGEL...

Share this post


Link to post
Share on other sites

  • 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!