PDA

View Full Version : drawing a circle



openglNewbie
02-04-2005, 03:32 PM
You probably know this by reading the subject to the thread, but I am new to opengl, glu, and glut.

Drawing a triangle, polygon, etc. is very straight forward, and I was hoping that would be the case with the circle.

My question is simple...is there an easy way to draw a circle (ie. give the x coordinate, the y coordinate, and the radius).

Any help would be greatly appreciated...

zukko
02-04-2005, 06:08 PM
hope this helps.

float radius = 2; // change this
glBegin(GL_LINE_STRIP) // or whatever you want
for(i=0;i<360;i++)
{
glVertex2f( radius*sin(i),radius*cos(i) );
}
glEnd();

dvm
02-04-2005, 10:18 PM
or alternatively you could try gluDisk. This is a glu quadric so it might be a bit hard to understand on first look, but it's easy afterwards.

openglNewbie
02-05-2005, 06:51 AM
Thank you for your help...