Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

fade out effect

4: Adsense

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   

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

#2 haegarr   Members   

7359
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.