• Create Account

## algortims for making circles in opengl

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

122
Like
Likes
Like

Posted 19 April 2000 - 02:29 AM

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

### #2a2k  Members

124
Like
Likes
Like

Posted 19 April 2000 - 09:08 AM

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.

122
Like
Likes
Like

Posted 19 April 2000 - 10:25 AM

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

### #4a2k  Members

124
Like
Likes
Like

Posted 19 April 2000 - 02:03 PM

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

### #5 Anonymous Poster_Anonymous Poster_*   Guests

Likes

Posted 19 April 2000 - 02:26 PM

Well, there is that gelDrawPerfectAss() function in OpenGEL...

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.