Advertisement Jump to content


This topic is now archived and is closed to further replies.


Game brightness

This topic is 5938 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a way to increase the overall brightness in your game window without increasing lighting. Maybe a pixel format setting or something like that.

Share this post

Link to post
Share on other sites
It''ll vary depending on the API you''re using, but searching your documentation for ''gamma'' should point you in the right direction. I''m not completely positive, but I think the gamma methods in D3D only work in full-screen mode. Good luck!

Share this post

Link to post
Share on other sites
MSDN does not give me any examples of these commands other than the syntax:

BOOL WINAPI SetDeviceGammaRamp(

What is the LPVOID data type? Can someone post an example of using GetDeviceGammaRamp() and SetDeviceGammaRamp().

I''m guessing you''d just call it like this:

if (GetDeviceGammaRamp(HDC, ???))
SetDeviceGammaRamp(HDC, ???)

Am I somewhat close to correct?


Share this post

Link to post
Share on other sites
First off, the HDC is kind of irrelevant since this only applies to the whole driver, i.e., you can''t apply it to just a window. So just use the DC for the desktop window (I''m assuming MS Windows btw. )

The LPVOID points to an array of 3*256 unsigned ints. 256 for the red channel, 256 for green, ...

It''s kind of tricky what''s going on. There''s a paper on the web somewhere that explains what gamma is in this context but I don''t have the link and I can''t remember the equation.

But, I have code! It''s something I hacked together a while back. It looks like poo but it worked at the time. Hope it helps.


// iGamma: ranges from -255 to +255; negatives make the screen "darker"


void AdjustGamma( int iGamma )
HDC hDC = GetDC(GetDesktopWindow());

bool bMinus = iGamma < 0;

if( bMinus )
iGamma = -iGamma;

iGamma = min(max(iGamma, 0), 255);

if( hDC ) {
const int iNum = 256;
struct sRamp {
WORD wRed[iNum];
WORD wGreen[iNum];
WORD wBlue[iNum];
} wRamp;
if( GetDeviceGammaRamp(hDC, (LPVOID)&wRamp) ) {
for( int i = 0; i < iNum; i++ ) {
if( bMinus ) {
wRamp.wRed[i] = (255 - iGamma)*(i);
wRamp.wGreen[i] = (255 - iGamma)*(i);
wRamp.wBlue[i] = (255 - iGamma)*(i);
} else {
wRamp.wRed[i] = 65535 - (255 - iGamma)*(255 - i);
wRamp.wGreen[i] = 65535 - (255 - iGamma)*(255 - i);
wRamp.wBlue[i] = 65535 - (255 - iGamma)*(255 - i);
BOOL bRet = SetDeviceGammaRamp(hDC, (LPVOID)&wRamp);
ReleaseDC(GetDesktopWindow(), hDC);

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!