How to change the brightness?

Hi

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
return;
}

glGetError ();

//switch to color matrix
glMatrixMode (GL_COLOR);

if (glGetError () != GL_NO_ERROR)
return;

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

if (glGetError () != GL_NO_ERROR)
return;

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

if (glGetError () != GL_NO_ERROR)
return;
}

I checked it, glGetError does not report any error.

Jan.

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

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.