• ### What is your GameDev Story?

#### Archived

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

# algortims for making circles in opengl

This topic is 6848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 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 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};

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 on other sites
Well, there is that gelDrawPerfectAss() function in OpenGEL...

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634092
• Total Posts
3015437
×