added vid_desktopgamma

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1501 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2005-10-18 04:42:13 +00:00
parent 6412c5d141
commit 3d531e6f45
2 changed files with 37 additions and 18 deletions

View file

@ -71,7 +71,6 @@ cvar_t r_stainfadeammount = {"r_stainfadeammount", "1"};
cvar_t _windowed_mouse = {"_windowed_mouse","1"};
cvar_t vid_wait = {"vid_wait","0"};
cvar_t vid_nopageflip = {"vid_nopageflip","0", NULL, CVAR_ARCHIVE|CVAR_RENDERERLATCH};
cvar_t _vid_wait_override = {"_vid_wait_override", "0", NULL, CVAR_ARCHIVE|CVAR_RENDERERLATCH};
static cvar_t vid_stretch = {"vid_stretch","1", NULL, CVAR_ARCHIVE|CVAR_RENDERERLATCH};
@ -235,6 +234,7 @@ cvar_t gl_lerpimages = {"gl_lerpimages", "1"};
extern cvar_t r_waterlayers;
cvar_t gl_triplebuffer = {"gl_triplebuffer", "1", NULL, CVAR_ARCHIVE};
cvar_t vid_hardwaregamma = {"vid_hardwaregamma", "1", NULL, CVAR_ARCHIVE};
cvar_t vid_desktopgamma = {"vid_desktopgamma", "0", NULL, CVAR_ARCHIVE|CVAR_RENDERERLATCH};
void GLRenderer_Init(void)
{
@ -243,6 +243,7 @@ void GLRenderer_Init(void)
Cvar_Register (&gl_triplebuffer, GLRENDEREROPTIONS);
Cvar_Register (&vid_hardwaregamma, GLRENDEREROPTIONS);
Cvar_Register (&vid_desktopgamma, GLRENDEREROPTIONS);
//renderer
Cvar_Register (&r_novis, GLRENDEREROPTIONS);
@ -441,7 +442,6 @@ void Renderer_Init(void)
//but register ALL vid_ commands.
Cvar_Register (&vid_wait, VIDCOMMANDGROUP);
Cvar_Register (&vid_nopageflip, VIDCOMMANDGROUP);
Cvar_Register (&_vid_wait_override, VIDCOMMANDGROUP);
Cvar_Register (&vid_stretch, VIDCOMMANDGROUP);
Cvar_Register (&_windowed_mouse, VIDCOMMANDGROUP);

View file

@ -142,15 +142,12 @@ qboolean isPermedia = false;
//====================================
// Note that 0 is MODE_WINDOWED
extern cvar_t vid_mode;
extern cvar_t _vid_default_mode;
// Note that 3 is MODE_FULLSCREEN_DEFAULT
extern cvar_t _vid_default_mode_win;
extern cvar_t vid_wait;
extern cvar_t vid_nopageflip;
extern cvar_t _vid_wait_override;
extern cvar_t vid_stretch_by_2;
extern cvar_t _windowed_mouse;
extern cvar_t vid_hardwaregamma;
extern cvar_t vid_desktopgamma;
extern cvar_t gl_lateswap;
int window_center_x, window_center_y, window_x, window_y, window_width, window_height;
@ -546,6 +543,7 @@ qboolean VID_SetFullDIBMode (rendererstate_t *info)
return true;
}
extern int gammaworks;
int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
{
@ -632,7 +630,14 @@ int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
vid.recalc_refdef = 1;
maindc = GetDC(mainwindow);
GetDeviceGammaRamp(maindc, originalgammaramps);
if (vid_desktopgamma.value)
{
HDC hDC = GetDC(GetDesktopWindow());
gammaworks = GetDeviceGammaRamp(hDC, originalgammaramps);
ReleaseDC(GetDesktopWindow(), hDC);
}
else
gammaworks = GetDeviceGammaRamp(maindc, originalgammaramps);
TRACE(("dbg: GLVID_SetMode: attaching gl\n"));
if (!VID_AttachGL(info))
@ -930,25 +935,25 @@ void GLVID_SetPalette (unsigned char *palette)
}
}
extern gammaworks;
void GLVID_ShiftPalette (unsigned char *palette)
{
extern unsigned short ramps[3][256];
// VID_SetPalette (palette);
if (ActiveApp && vid_hardwaregamma.value) //this is needed because ATI drivers don't work properly (or when task-switched out).
{
if (gammaworks)
{ //we have hardware gamma applied - if we're doing a BF, we don't want to reset to the default gamma (yuck)
SetDeviceGammaRamp (maindc, ramps);
if (vid_desktopgamma.value)
{
HDC hDC = GetDC(GetDesktopWindow());
gammaworks = SetDeviceGammaRamp (hDC, ramps);
ReleaseDC(GetDesktopWindow(), hDC);
}
else
gammaworks = SetDeviceGammaRamp (maindc, ramps);
return;
}
gammaworks = !!SetDeviceGammaRamp (maindc, ramps);
}
else
gammaworks = false;
}
@ -960,7 +965,15 @@ void VID_SetDefaultMode (void)
void GLVID_Shutdown (void)
{
SetDeviceGammaRamp(maindc, originalgammaramps);
if (vid_desktopgamma.value)
{
HDC hDC = GetDC(GetDesktopWindow());
SetDeviceGammaRamp(hDC, originalgammaramps);
ReleaseDC(GetDesktopWindow(), hDC);
}
else
SetDeviceGammaRamp(maindc, originalgammaramps);
gammaworks = false;
VID_UnSetMode();
@ -1124,8 +1137,14 @@ void GLAppActivate(BOOL fActive, BOOL minimize)
v_gamma.modified = true; //wham bam thanks.
SetDeviceGammaRamp(maindc, originalgammaramps);
gammaworks = false;
if (vid_desktopgamma.value)
{
HDC hDC = GetDC(GetDesktopWindow());
gammaworks = SetDeviceGammaRamp (hDC, originalgammaramps);
ReleaseDC(GetDesktopWindow(), hDC);
}
else
gammaworks = SetDeviceGammaRamp(maindc, originalgammaramps);
}
}