Does anyone know how I can achieve the following effect in OpenGL:
On win32 you can use SetDeviceGammaRamp to adjust the overall brightness / gamma. However, this affects the entire display so it's not a good idea unless your app is fullscreen.
The portable alternative is to either draw the entire scene brighter or dimmer (which is a hassle), or to slap a fullscreen alpha-blended quad over the whole scene to brighten or darken it as desired. Neither of these approaches can affect the gamma-curve, only the overall brightness; to adjust the gamma you need grab the entire scene into a texture and then render it back to the screen via a pixel-shader that runs each texel through a gamma function.
Ok, having read the updated question, what you need is a quad with blending set up to darken or brighten everything underneath it. Eg.
if( brightness > 1 )
{
glBlendFunc( GL_DEST_COLOR, GL_ONE );
glColor3f( brightness-1, brightness-1, brightness-1 );
}
else
{
glBlendFunc( GL_ZERO, GL_SRC_COLOR );
glColor3f( brightness, brightness, brightness );
}
glEnable( GL_BLEND );
draw_quad();
http://www.gamedev.net/community/forums/topic.asp?topic_id=435400 might be an answer to your question otherwise you could probably implement a gamma correction as a pixel shader