View Full Version : drawing circle

11-25-2000, 07:57 AM
Hope my question does not sound too dumb? I looked under various help files and still I could not find the built in function that will draw circle or ellipse. I was hoping to have something of the form glCircle()....
Your help will be appreciated.

11-25-2000, 08:25 AM
OpenGL go no build in functions for drawing primitives (other that points, lines and triangles) at all. If you want primitives other than the one i mentioned, you must look at either the glu-library or GLUT. These are the two most common libraries that uses OpenGL.

11-25-2000, 08:34 AM
Or simple try:
(x, y, z) the center of the circle, r=radius, a=angle
do {
glPoint(x+sin(a)*r, y+sin(a)*r, z);
} while (a<360);

I don't know about the syntax of glPoint, but in this case it would be (x, y, z);
If you want different circles, try using cos instead of sin or switching the sin's.
For elipses use something like this:
rx=xradius, ry=yradius
do {
glPoint(x+sin(a)*rx, y+sin(a)*ry, z);
} while (a<360);

another example would be:
dlPoint(x-cos(a)*rx, y+sin(a)*ry, z-sin(-a)*rz);

Feel free to experiment.
Hope that helps - Ls

11-25-2000, 08:36 AM
I'm sorry, but of course you have to increase a by 1 or 0.1 or something like this. And you also could try lines between a and a+0.1, they will even give a circle at the biggest radius, instead of making it a circle of points. Ls