How to draw a circle or a arc filled with color in OpenGL?

Started by
0 comments, last by foreveryung 22 years, 4 months ago
How to draw a circle or a arc filled with color in OpenGL?
Advertisement
I guess you can use a triangle fan. Try something like this:

  glBegin(GL_TRIANGLE_FAN);glVertex3f(0.0f, 0.0f, 0.0f)float i;for (i = 0; i <= 360.0f; i += 360/num_steps)     glVertex3f(cos(DEGTORAD * i) * radius,           sin(DEGTORAD * i) * radius, 0.0f);glEnd();  



Assume that num_steps is sorta the level of detail of the circle. Basically it''s how circular your circle is going to be. In actuality, this really just creates a regular polygon with num_steps sides. If num_steps is around 30 maybe, it will look close to a circle. radius is the radius of the circle, and DEGTORAD is pi/180.

Did your file get a virus or is your coding always this bad?

This topic is closed to new replies.

Advertisement