Jump to content
  • Advertisement
Sign in to follow this  
asdfwe

colour fill help

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Approximate the circle as a fan of triangles (OpenGL cannot render circles natively) and render those triangles with the specified vertex color.

Share this post


Link to post
Share on other sites
can u please tell the modification required in this code to fill colour in the circle made................

glBegin(GL_LINES);
for ( float angle =0; angle <=2*3.142; angle+=3.142/30)
{

float x1=(radius * cos (angle) / 2) ;
float y1=(radius * sin (angle) / 2) ;
float x2=(radius * cos (angle + 3.142/30) / 2 ;
float y2=(radius * sin (angle + 3.142/30)/ 2) ;
glVertex2f(x1,y1);
glVertex2f(x2,y2);
}
glEnd();

Share this post


Link to post
Share on other sites
Changing your code as little as possible, I get this:
glBegin(GL_TRIANGLE_FAN);
glVertex2f(0,0);
for ( float angle =0; angle <=2*3.142; angle+=3.142/30)
{
float x1=(radius * cos (angle) / 2) ;
float y1=(radius * sin (angle) / 2) ;
glVertex2f(x1,y1);
}
glVertex2f(radius * cos (angle) / 2, radius * sin (angle) / 2);
glEnd();

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!