Dear all,
I want to render a background with gradient colors, say from green to white, but I don’t know how, any hints or suggestions?
Thanks.
Dear all,
I want to render a background with gradient colors, say from green to white, but I don’t know how, any hints or suggestions?
Thanks.
A simple quad, with 2 color parameters, should be enough.
This works, however this quad rotates as I manipulate the scence with mouse, as is not expected; and also, some of lines I render are not visible after using this code. Any hints?
[This message has been edited by kangarooxy (edited 10-27-2003).]
The background drawing needs its own modelview projection matrix.
Disable depth test for the background.
Easiest code (not tested):
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, 1.0, -1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST); // Color buffer only rendering
glBegin(GL_QUADS);
glColor3fv(bottomColor);
glVertex2f(-1.0f, -1.0f);
glVertex2f( 1.0f, -1.0f);
glColor3fv(topColor);
glVertex2f( 1.0f, 1.0f);
glVertex2f(-1.0f, 1.0f);
glEnd();
…
// Put your other code which sets up its own projection and modelview matrices here.
// Don’t forget to clear the depth buffer.