08-06-2001, 09:35 PM

How would you go about drawing a circle in openGL. I''m sorry, I know it's a stupid question, but I've only been looking at openGL for a week.... Thanks

View Full Version : Circles

08-06-2001, 09:35 PM

How would you go about drawing a circle in openGL. I''m sorry, I know it's a stupid question, but I've only been looking at openGL for a week.... Thanks

john

08-07-2001, 04:53 PM

Hello,

this has been done before, methinks. But, ah well, I am in a chirpy mood today, so ... <deep breath>:

glBegin(GL_LINE_LOOP);

for(int t=0; t<CIRCLE_RES; t++) {

float angle=((float)t/(float)CIRCLE_RES)*2.0*M_PI;

glVertex2f(cos(angle), sin(angle));

}

glEnd();

which will draw a unit circle with z=0. SO, you'll want to scale it and translate it, 'n' stuff. But i'm sure you know all that.

cheers,

John

this has been done before, methinks. But, ah well, I am in a chirpy mood today, so ... <deep breath>:

glBegin(GL_LINE_LOOP);

for(int t=0; t<CIRCLE_RES; t++) {

float angle=((float)t/(float)CIRCLE_RES)*2.0*M_PI;

glVertex2f(cos(angle), sin(angle));

}

glEnd();

which will draw a unit circle with z=0. SO, you'll want to scale it and translate it, 'n' stuff. But i'm sure you know all that.

cheers,

John

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.