There are two problems with this code to draw a circle.
One is that it is rendered in the center of the view even though I have glViewport(0, 0, size.width, size.height); earlier, so the origin should be in 0, 0. The second is how to control the diameter of the circle, as it is is automatically the view's width (and height, if the view's aspect ratio is not 1/1, so that it is an oval). I am not sure if this is a good way to draw a circle in OpenGL. How to solve these problems?
Code:
glBegin(GL_POLYGON);
{
for(i=0;i<100;i++)
{
cosine=cos(i*2*PI/100.0);
sine=sin(i*2*PI/100.0);
glVertex2f(cosine,sine);
}
}
glEnd();