GetDeviceGammaRamp() not returning proper gammaramp

Started by
0 comments, last by jitspoe 20 years, 8 months ago
I''m fiddling with using gammaramps in Quake2, but I''ve run into a problem with saving the desktop gammaramp settings. It seems to always use the standard, straight ramp, no matter what color correction settings I have set in the drivers. Here''s my code:

WORD desktop_gammaramp[3][256]; // jitgamma
qboolean gammaramp_supported;

void printgammaramp  () // for debugging
{
	FILE *blah;
	int i;

	blah = fopen("C:/gammaramp.txt","w");
	for(i=0;i<256;i++)
		fprintf(blah,"%d %d %d\n", desktop_gammaramp[0], desktop_gammaramp[1], desktop_gammaramp[2]);
}

void VID_BackupGamma() // jitgamma
{
	HDC	hdc;

	hdc = GetDC (GetDesktopWindow());
	gammaramp_supported = GetDeviceGammaRamp (hdc, &desktop_gammaramp[0][0]);
printgammaramp();
	ReleaseDC (GetDesktopWindow(), hdc);
}

void VID_RestoreGamma() // jitgamma
{
	if(gammaramp_supported)
	{
		HDC	hdc;

		hdc = GetDC (GetDesktopWindow());
		SetDeviceGammaRamp (hdc, &desktop_gammaramp[0][0]);
		ReleaseDC (GetDesktopWindow(), hdc);
	}
}
 </pre> 

I''ll go into the driver settings and crank the red channel way up, for example, then run quake2, and when I quit, the gamma ramp goes back to the default settings (red isn''t bright).

Here''s what gammaramp.txt <i>always</i> looks like:
0 0 0
256 256 256
512 512 512
768 768 768
1024 1024 1024
…
64768 64768 64768
65024 65024 65024
65280 65280 65280

Any ideas?  </i>  

    
___________________________________Digital Paint: Paintball 2.0jitspoe's joint
Advertisement
I''m guessing that the drivers set the gamma using something other than SetDeviceGammaRamp, but when my game uses SetDeviceGammaRamp(), it overrides the other gamma setting. I need to figure out how to restore windows to the way it was when the game exits.
___________________________________Digital Paint: Paintball 2.0jitspoe's joint

This topic is closed to new replies.

Advertisement