fade out effect

Started by
0 comments, last by haegarr 10 years ago
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();
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(); 

This topic is closed to new replies.

Advertisement