View Full Version : gamma in opengl & windows
I'm making some stuff in opengl, and screen is too dark. And I know there is such thing as SetDeviceGammaRamp... in windows. But The commands does not work on winNT with my drivers :[[, but changig gamam in q3 works, and I beleive than SetDeviceGammaRamp is used in q3. Any suggestins ?
01-05-2001, 11:02 AM
Are you certain that the SetDeviceGammaRamp function doesn't work? I had trouble getting it to work with Win98 till I discovered that I could not send it the HDC of the window. It had to be the HDC of the device by using GetDC(NULL).
for exmaple this does not work
memset(lpRamp, 0, sizeof(lpRamp));
if (SetDeviceGammaRamp(GetDC(NULL), lpRamp) == FALSE) MessageBox(NULL, "SSS1111111111", "DF", MB_OK);
01-05-2001, 01:40 PM
Well, in that case, it looks like your video card driver does not support the function, or perhaps your ramp array is too small (doubt it since it doesn't crash). I can't tell what size elements you are using but I assume you are using WORD type elements. If the driver doesn't support the function, then I seriously doubt that Q3 is using it to any effect either. Instead Q3 is probably resorting to adjusting the gamma of the textures manually or playing with overbright bits.
[This message has been edited by DFrey (edited 01-05-2001).]
well, I use WORD lpRamp;
AnD I'm using TNT2 Ant Win2000
& NVIDIA Display Driver for Windows 2000 version 6.31, 09/20/2000
And q3 version
1.25 does not seems to work with SetGammaRamp
But 1.27g works, I tried runing q3 in windoze and adjustng gamma, in q3 and gamma of desktip changes too. So what is done in q3 that this works ?
01-06-2001, 07:19 AM
It must be an OS issue. I have the same video card and use the same driver version, except for Win98. Maybe try using CreateDC("DISPLAY",NULL,NULL,NULL); to get the HDC. Remember to delete the DC after you are finished with it (assuming you are given it).
[This message has been edited by DFrey (edited 01-06-2001).]
01-06-2001, 07:27 AM
Hehe, I looked back at my code and it turns out I used the CreateDC function to make a HDC for the display device since I could not get the one returned from GetDC(NULL) to work. I looked at the specs for CreateDC and I do not think it will work in WinNT as I wrote it above. It appears in WinNT, according to the documentation, that second parameter can not be NULL (in Win98 it can in this particular instance) but must be the name of the device being used. So looks like you need to get the name of the display device first for WinNT in order to use this function. I'm not quite certain how to go about doing that at this moment.
01-06-2001, 07:30 AM
Ok just learned you use EnumDisplayDevices to get that info for the CreateDC. http://www.opengl.org/discussion_boards/ubb/smile.gif
I tried such programs as PowerStrip
and that program is able to change gamma.
I woud like to know how it's done. Since Then I use SetDeviceGammaRamp does not work on Win2000.
Read about this other funcs:
-CreateColorSpace / SetColorSpace
Also, the docs say about SetDeviceGammaRamp that "Some display adapters support downloadable gamma correction tables", notice the word "Some". This means that is perfectly valid for the display driver not to expose this functionality. Maybe it simply doesn't work on NT, and you have to manually alter textures and colors with your own gamma functions.
SetDeviceGammaRamp doesnt work 100% either on win2000 (sometimes does sometimes doesnt) what i do is alter a textures 'gamma' when i load it in.
BTW with quake3 u have to disable gamma as well in win2000
Well I have Installed q3 patch 1.27g and now changing gamma works on Win2000 same as in win98. So I suppose somthing is done in q3 that this thing works normaly. And no need to make texture brighter. So what is done in q3. I thing It's mae bay sing SetDeviceGammaRam, Beause I have started q3 in windowed mode & while changing gamma in q3
(r_gamma) the colors on desktop where cahnging too.
01-08-2001, 09:58 AM
Did you try using CreateDC("DISPLAY",devicename,NULL,NULL) to get the hdc for SetDeviceGammaRamp?
Well, now changing gamma works fine for me on win2000. I think that the problem was not getting right DC, but calculating correct gamma values. I vas getting old gamma ramp and increasing all walues by 1 (or any other constant) and getting nothing. And Later I found one example in theese discusions, whitch calculates that ramp. And Now it works. The code look like this (i modiefied it a little)
int i, j, min, max = 0;
memset(NewRamp, 0, sizeof(NewRamp));
for (i = 0; i < 3; i++)
min = 256 * i;
max = min + 256;
for (j = min; j < max; j++)
NewRamp[j] = pow(((j % 256) / 256.0), 1/cfg.r_gamma) * 65536;
01-09-2001, 04:57 AM
Oh heck, I could of shown you that. http://www.opengl.org/discussion_boards/ubb/tongue.gif I also have brightness and contrast built into my gamma code. http://www.opengl.org/discussion_boards/ubb/smile.gif
Now I'd like to see that http://www.opengl.org/discussion_boards/ubb/smile.gif I havent even gotten to the point of changing the gamma, I just set it to be overbright, I'd like to have a full assortment of adjustments though.
01-09-2001, 05:11 AM
Here (http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/000775.html) is the thread in which I displayed the code I used. You could use it as a starting point at least. It really needs some constraints built in because it is too flexible! http://www.opengl.org/discussion_boards/ubb/biggrin.gif
Could someone please point me to info on 3DFX_gamma_control extension?? I've looked on 3dfx's site, on SGIs site, in the extension database on gamedev.net, and in various other places. I know it exists http://www.opengl.org/discussion_boards/ubb/smile.gif
01-09-2001, 09:12 AM
Here is an unofficial doc http://www.pseudonymz.demon.co.uk/gam3dfx.txt I have no idea if it is correct however. Oh, and just to be precise, it is the WGL_3DFX_gamma_control extension. http://www.opengl.org/discussion_boards/ubb/biggrin.gif
[This message has been edited by DFrey (edited 01-09-2001).]
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.