I am wondering how could I optimize my circle draw method. I seek how to generate as quickly as possible the vertices, before sending them to opengl.
void DrawCircle(float x, float y, float radius, Color color, float thickness)
{
int numOfPoints = 100;
for (float i = 0; i < numOfPoints; ++i) {
float pi2 = 6.28318530718;
float angle = i / numOfPoints * pi2;
FillRect(
cos(angle) * radius + x,
sin(angle) * radius + y,
thickness,
thickness,
color);
}
}
FillRect function simply draws a quad, so DrawCircle function draws 100 quads which are moved by cos, sin and radius.
FillRect(float x, float y, float w, float h, Color color)
How could I draw circle different way?