Archived

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

jitspoe

GetDeviceGammaRamp() not returning proper gammaramp

Recommended Posts

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][i], desktop_gammaramp[2][i]);
}

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);
	}
}
 
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 always 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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites