# draw a circle??

how can i draw a simple circle using opengl ??plz help

you can use GL_LINE_LOOP computing each circle points coordinates

hello,
I’ve been looking for a solution on how to draw a circles or arcs with opengl. I found a way by myself. In fact you create a RGBA texture displaying the circle you want, can be a disk or any circular thing you like. You just need to make transparent parts of the textures that are not expected to be drawn.
To draw a full circle, it’s easy, you just have to draw a textured quad with blending activated. If you want to just draw an arc, you have to divide your quad in several triangles which have the center of the circle as a common vertex. Here is the code (I’m french, it helps to understand the names, etc…), the code is for ortho mode so only 2D in glVertex, but it’s easy to adapt to 3D:

Now you say “what is this AddAngCerc function called?”.
It’s just a function calculating addx and addy, it means what is the position of the limit of the square according the angle. It just gives a number between 0 and 1 and is then multiplied by the number we like. As it is in [0,1], we just calculate it once to be used in glTexCoord and glVertex. Here is the code:

So that’s the answer I found to drawing a circle in opengl (and as it’s textured, results can be really nice).
Have a look at two circles drawn there:
http://img169.imageshack.us/my.php?image=image2qg3.jpg
Hope it will help anybody.
David

If it’s a filled circle:

glEnable(GL_POINT_SMOOTH);
glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);