   How can I do Gamma correction in OpenGL?
  Most games have Gamma correction settings to adjust brightness in game.  Does OpenGL provide such feature? If not, is there any other way to do it?   
  Hmmm, I'm not sure about this, but how about blending a white quad that covers the while screen in ortho mode?  you can define the color like this glColor( 1.0f, 1.0f, 1.0f, gamma ), where gamma is a value from 0.0f (no gamma correction) to 1.0f (full gamma correction).  I haven't tried this yet, but should work.  Oh yeah, remember to turn the depth test off while doing this.Brain21   ;  Gamma correction is usually a feature of the platform's windowing API, if you are using a cross platform API such as SDL or Allegro it may have a cross-platform abstraction of Gamma functions. (I can't remember offhand whether either of those libraries does, but I know I saw it somewhere...)   ;  it can be done as a shader postprocess effect (Thanks NVSDK!) using the following formula:Color = pow(Color, Gamma); //or n-gamma (n >= gamma), try it and you'll see why.;  Thanks alot!  I'll try it :)   ;Quote:Original post by Code-Rit can be done as a shader postprocess effect (Thanks NVSDK!) using the following formula:Color = pow(Color, Gamma); //or n-gamma (n >= gamma), try it and you'll see why.It should be corrected = pow( color, 1.0f / gamma )So a gamma of 2.2 will brighten you image;  Mmmm...I've already done that, but I had to use a platform dependent function call. There is a function called SetDeviceGammaRamp or something like that in the windows API. You must pass a pointer with WORD values representing the gamma curve you want to apply to the device...It's pretty simple, but I don't have the code right here. I'll post it when I get home.The problem I had with it is that it seems you must perform the call at some precise point while initializing the GL context, or you won't see any gamma change. I'm currently working on this weird behaviour, as I made some changes in my engine and the gamma correction has stopped working :(¿Anyone knows something about this?   ;  Here's the code I use:The windows API funcion prototype is:BOOL WINAPI SetDeviceGammaRamp(HDC hDC,LPVOID lpRamp);You need a DC (the DC context bound to the GL), and a piunter to a WORD[256*3] containing the color conversion to be applied for all color levels.A little code to set up a gamma ramp is as follows:Vector3 rgb(1.0,1.0,1.0);float gFactor;for (int i =0;i<3;i++)  {gFactor=(i==0)?rgb.x:(i==1)?rgb.y:rgb.z;    for (int j=0;j<256;j++)  pGammaRamp[(i<<8)+j] =(WORD) MIN(65535,MAX(0,(powf(((float)j)/256.0f,gFactor) * 65536)));} The rgb vector contains the gamma ramp to apply to each color channel. The lower the value, the brighter the screen will be (1 will generate a linear ramp).There is also another Windows API funcion that may come in handy:BOOL WINAPI GetDeviceGammaRamp(  HDC hDC,  LPVOID lpRamp);Again, you need the GL Device Context (HDC) and an allocated array of 256*3 WORDS, in wich the function will place the current device gamma ramp.The problem with this function calls, as I mentioned in my previous post, is that it will only work if you call it in the right place (somewhere within the initialization of the GL context). I'm investiagating on this subject, as I've been doing some changes in my code that made the gamma ramp dont work.Hope this helps.Regards,;  Hi, great thx for the one who ask this question! And dorodo too! I've asked not so long ago and i've dosen't have the answer i was waiting for. The SetDeviceGammaRamp API was the solution. derodo->I've pluged you're code into my app. and it work very well. And it workanywhere in my game. What suck is that it affect all my windows(more exactly, the full screen), like if i was giving the desktop hDC instead of my game windows hDC... Strange, no??? dorodo->Did it does also that on your computer??? If anyone has the answer...