Archived

This topic is now archived and is closed to further replies.

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

This topic is 6151 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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

Share on other sites
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.

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 103
• 11
• Forum Statistics

• Total Topics
632976
• Total Posts
3009672
• Who's Online (See full list)

There are no registered users currently online

×