drawing circles in opengl

i need to develop a simple drawing tool in opengl which will let me draw points, lines, circles and ellipses. these options must be availble by clicking the right mouse button. i can include a line and points but can’t get circles to work.

help please

You’ll need to “simulate” circles with lines.

You’ll need to “simulate” circles with lines.

try a for-next loop and rotate and then translate out the length of the radius.
I did something like this before, allowing you to choose the number of lines is usefull so you can have anything from a pentagon to a pixel perfect circle.

Rotate and translate out of the radius? huh!? It’s far easier just to zzap the verticies:

for(int i=0; i<CIRCLE_RESOLUTION; i++) {
float ang=((float)i/(foat)CIRCLE_RESOLUTION)2.03.14159265;
glVertex2f(cos(ang)*rad, sin(ang)*rad);


I wanna be a nudist \ And live by the sea \ I wanna be a buisness man \ Drinking lots of coffee — Regurgitator

It may be easier, but it isn’t as nice and it isn’t as fast.

simulating the circle is easiest done with sin and cos, it is useful to know that sin and cos are modelled on a circle, sin and cos of an angle will produce two new values which can represent proportional vertices of a circle.