View Full Version : Modifying gamma correction in Opengl

02-06-2002, 12:31 AM
Does Opengl provide a way to modify the gamma settings? Win32 provides the command "SetDeviceGammaRamp" but it is hardware-dependent. I don't want to mess with the color ramp, I just want to lighten or darken my scene. Does anyone know any other way ( I want to darken/lighten all objects in my scene , some of which are drawn with GL_LIGHTING disabled, so altering the light settings won't work)

02-06-2002, 12:58 AM
Lighten or darken doesn't mean modifying gamma correction, gamma doesn't simply change the darkness/lightness of the screen.

If you have a dark scene just brightening it won't change the quality of the scene, U'll just get the same scene with the same CONTRAST but more bright, for example if you draw a really dark picture and then just raise the brightness of your monitor won't make that picture look better, changin the gamma correction would.

Anyway, the commonly used way it's to use the SetGamma function.

Dunno if there is another one...

rIO.sK http://www.spinningkids.org/rio

02-06-2002, 01:13 AM
To brighten the whole scene you could just draw a white transparent quad all over the screen. Results are not very good, though.

You can also use the color matrix in OpenGL, but it's so rarely implemented that I think we'll have HW 3D textures before HW color matrix.

But with the "translucent quad over the screen" trick, you can achieve very neat effects depending on what you really want to do on your scene.
Is it about contrast ? brightness ? color ?

[This message has been edited by vincoof (edited 02-06-2002).]

02-06-2002, 05:54 AM
Rendering a quad all over the screen doesnot sound that fast to me http://www.opengl.org/discussion_boards/ubb/smile.gif
Anyway, I just wanted to alter the gamma correction to brighten my screen, since I don't know whether there is any way to change the brightness or contrast in the rendering window.

02-06-2002, 06:37 AM
Rendering a white quad is not that slow, especially if you do it only one time per frame.
On a GeForce2, you can approximatively draw 100 "full" quads per second, blended and textured, without any significant loss ! (on a 1024x768x32 res)
That means, if your application runs at 50fps you can "freely" perform 2 passes.

GLfloat brightness = 0.2f;
/* Disable here as many states as you want */
glColor3f(brightness, brightness, brightness);
glBlendFunc(GL_ONE, GL_ONE);
/* Don't forget to enable here states that were disabled */
/* And don't forget to set the blending function if needed */

Use the 'brightness' value to enlight your scene differently.
A brightness that equals zero enlights nothing, but darkens nothing too.
A brightness that equals one forces all the scene to be white.

To get different effects (for example, darkening the scene) you have to change the glBlendFunc arguments and/or the glColor arguments.