PDA

View Full Version : How to change the brightness?



Jan
01-14-2003, 06:52 AM
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.

Tom Nuydens
01-14-2003, 07: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

jwatte
01-14-2003, 11: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.