Jump to content

  • Log In with Google      Sign In   
  • Create Account


fade out effect


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 saransh   Members   -  Reputation: 59

Like
0Likes
Like

Posted 30 April 2014 - 07:36 AM

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();

Sponsor:

#2 haegarr   Crossbones+   -  Reputation: 3991

Like
0Likes
Like

Posted 30 April 2014 - 07:58 AM

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, 30 April 2014 - 07:59 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS