Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: How to change the brightness?

  1. #1
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,042

    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.

    Code :
    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.
    GLIM - Immediate Mode Emulation for GL3

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    807

    Re: How to change the brightness?

    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

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,411

    Re: How to change the brightness?

    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.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •