View Full Version : Drawing a circle with OpenGL

11-08-2000, 11:45 AM
Hi, I hope to find a easy solution for my problem. I want to draw a circle with OpenGL and I havn't found a method to do this. I have to write a program which shows/explains the "Bresenham Algorhytm" (when you draw a line or a circle it would be drawn this way). I solved this and it works, but is there no chance to draw a circle with a single funktion call?

I hope this question isn't to simple http://www.opengl.org/discussion_boards/ubb/smile.gif

11-08-2000, 06:59 PM
With one function call?

Though it's expensive, you can always use glu or glut to draw a torus. Just use a very small number for the ring thickness, and don't scale it.

<shrug> Or you could create a routine that draws the points with GL_BEGIN(GL_POINTS) and run through a while loop which increments a counter and puts the counter through an algorithm to generate x, y coords for a circle. But, that depends on how important it is to have _only_ one function.


BTW, just noticed about 6 posts down, the thread about elipses is pertinent. Check it out Spiderman.

[This message has been edited by Glossifah (edited 11-08-2000).]

11-09-2000, 04:06 AM
Some code (not tested) to draw a circle with lines

GLfloat sphereCenterX, sphereCenterY;
GLfloat x, y, radius = 1;

glColor3f(0, 0, 1);


x = sphereCenterX+radius*sin(0.0174f * 0);
y = sphereCenterY+radius*cos(0.0174f * 0);
glVertex2f(x, y);

for(i = 20; i < 360; i+=20) {
x = sphereCenterX+radius*sin(0.0174f * i);
y = sphereCenterY+radius*cos(0.0174f * i);
glVertex2f(x, y);


11-09-2000, 04:12 AM
If you can use the GLU lib, u can use the gluDisk function. To know more about it, go to the flowwing URL:

11-09-2000, 04:18 AM
I'm gonna try this ...