View Full Version : How to change the brightness?

01-14-2003, 05:52 AM

The "SuperBible" has a chapter, where it describes how to change brightness and contrast. I implemented this function and tested it, but it has no effect. There seem to be no errors, however nothing changes in my program. Maybe one of you knows if there is something missing.

void Brightness (float bright)
if (strstr ((const char*) glGetString (GL_EXTENSIONS), "ARB_imaging") == NULL)
//ARB_imaging not supported

glGetError ();

//switch to color matrix
glMatrixMode (GL_COLOR);

if (glGetError () != GL_NO_ERROR)

//change brightness
glTranslatef (bright, bright, bright);

if (glGetError () != GL_NO_ERROR)

//switch back to modelview matrix
glMatrixMode (GL_MODELVIEW);

if (glGetError () != GL_NO_ERROR)

I checked it, glGetError does not report any error.


Tom Nuydens
01-14-2003, 06:09 AM
The color matrix does not affect rasterized primitives -- it only operates on the pixel path. Are you using glDrawPixels() or glCopyPixels()? If not, the color matrix won't have any effect.

If you want brightness controls for rendered primitives, you can do so by adjusting your gamma. Alternatively, you could implement your own color matrix functionality using a pixel shader.

-- Tom

01-14-2003, 10:10 AM
The simplest way of implementing "cheesy" brightness and contrast is to increase the diffuse power of your light and decrease the power of ambient for higher contrast, and to increase the level of ambient for higher brightness.