GL_LINE_LOOP
you can use thick lines instead of rectangles that way you decrease glVertex
calls from 4 to 1 per "pixel". It would look something like this:
void DrawCircle(float x, float y, float radius, Color color, float thickness)
{
const int numOfPoints = 100;
const float pi2=6.28318530718;
const float da=pi2/numOfPoints;
float a;
glColor3f(color.r,color.g,color.b);
glLineWidth(thickness/2.0);
glBegin(GL_LINE_LOOP);
for (a=0;a<pi2;a+=da) glVertex2f(cos(a)*radius + x, sin(a) * radius + y);
glEnd();
glLineWidth(1.0);
}
of coarse as I do not know how the color
is organized the color settings might change. Also glLineWidth
is not guaranteed to work for arbitrary thickness ...
If you want still to use GL_QUADS
then at least turn it to GL_QUAD_STRIP
which will need half of the glVertex
calls...
void DrawCircle(float x, float y, float radius, Color color, float thickness)
{
const int numOfPoints = 100;
const float pi2=6.28318530718;
const float da=pi2/numOfPoints;
float a,r0=radius-0.5*thickness,r1=radius+0.5*thickness,c,s;
int e;
glColor3f(color.r,color.g,color.b);
glBegin(GL_QUAD_STRIP);
for (e=1,a=0.0;e;a+=da)
{
if (a>=pi2) { e=0; a=pi2; }
c=cos(a); s=sin(a);
glVertex2f(c*r0 + x, s * r0 + y);
glVertex2f(c*r1 + x, s * r1 + y);
}
glEnd();
}