Hi folks,
I’m doing something pretty basic, but being the beginner I am, I’ve run into a brick wall, head first.
I’ve got a 2D (orthographic) app. I have a “window” assembled by a series of quads and line loops, and I want to fade it out. Is there a way to do this without modifying the glColor alpha parameter for every single vertex?
Could I do something like this?
- Enable lighting
- Set the lighting alpha value to match the current alpha at this point in the fade
- Render the “window”
- Disable lighting
It seems like quite a hack, and when I’ve tried it, the quads and line loops turn white. The code I’m using for the fade effect is below:
void Fade::Begin()
{
glEnable(GL_LIGHTING);
GLfloat light0[] = {0.0f, 1.0f, 1.0f , 1.0f};
glLightfv(GL_LIGHT0, GL_AMBIENT, light0);
glEnable(GL_LIGHT0);
Glfloat global_ambient[] = {0.5f, 0.5f, 0.5f, m_alpha};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);
}
void Fade::End()
{
glDisable(GL_LIGHT0);
glDisable(GL_LIGHTING);
}
I feel like I’m going entirely in the wrong direction. Any suggestions?