Advertisement

Filled Circle

Started by April 24, 2003 08:28 AM
2 comments, last by Sarashinai 21 years, 10 months ago
I''m trying to figure out a way of drawing a filled circle. I want to be able to make it any size I want of any color. Does OpenGL have an easy way to do this?
gluDisk.
Advertisement
Agreed, use some quadrics. lesson 18(i think) teaches you how to use them.
=============================================Want to be paid for using your programming/graphics skills from home?Then become a Freelancer today! www.FreelanceUK.net=============================================

  #include <math.h>void disk(GLdouble radius, GLuint slices){ GLuint i; glBegin(GL_TRIANGLE_FAN); glVertex2i(0,0); for (i=0;i<=slices;i++) {   GLdouble angle = (GLdouble)i*M_PI*2. / (GLdouble)slices;   glVertex2d(radius*cos(angle), radius*sin(angle)); } glEnd();}  



This is the standard way.
You can also skip the first and last vertices (slightly faster) :

  #include <math.h>void disk(GLdouble radius, GLuint slices){ GLuint i; glBegin(GL_TRIANGLE_FAN); for (i=0;i<slices;i++) {   GLdouble angle = (GLdouble)i*M_PI*2. / (GLdouble)slices;   glVertex2d(radius*cos(angle), radius*sin(angle)); } glEnd();}  


You can set this into a display list, which is recommended if the number of slices is "big".

This topic is closed to new replies.

Advertisement