• Advertisement
Sign in to follow this  

fade out effect

This topic is 1361 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

So I have this polygon and I want to give it a fade out effect it needs to go from dark blue at top to light blue at the bottom... how do I do it?





glColor3f(0.0, 0.0, 1.0);
glBegin(GL_POLYGON);
glVertex2f(0.6,-1.0);
glVertex2f(2.0, -1.0);
glVertex2f(2.0,0.13);
glVertex2f(0.6, 0.13);
glEnd();

Share this post


Link to post
Share on other sites
Advertisement

To give it a color gradient, you need to specify different colors to the particular vertices. The color which is set just before glVertex is called will be used for that vertex. E.g.

glBegin(GL_POLYGON);
// 1st vertex
glColor3f(0.5, 0.5, 1.0);
glVertex2f(0.6,-1.0);
// 2nd vertex
glColor3f(0.5, 0.5, 1.0);
glVertex2f(2.0, -1.0);
// 3rd vertex
glColor3f(0.0, 0.0, 1.0);
glVertex2f(2.0,0.13);
// 4th vertex
glColor3f(0.0, 0.0, 1.0);
glVertex2f(0.6, 0.13);
// done
glEnd(); 
Edited by haegarr

Share this post


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

  • Advertisement