A bit of fun with gamma.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1942 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2006-02-11 02:05:15 +00:00
parent 8e7eda07e6
commit bc1f25a11b

View file

@ -203,6 +203,8 @@ BOOL (WINAPI *qSwapBuffers)(HDC);
BOOL (WINAPI *qwglSwapIntervalEXT) (int); BOOL (WINAPI *qwglSwapIntervalEXT) (int);
BOOL (APIENTRY *qGetDeviceGammaRamp)(HDC hDC, GLvoid *ramp);
BOOL (APIENTRY *qSetDeviceGammaRamp)(HDC hDC, GLvoid *ramp);
qboolean GLInitialise (char *renderer) qboolean GLInitialise (char *renderer)
{ {
@ -258,6 +260,12 @@ qboolean GLInitialise (char *renderer)
qwglMakeCurrent = (void *)getwglfunc("wglMakeCurrent"); qwglMakeCurrent = (void *)getwglfunc("wglMakeCurrent");
qSwapBuffers = SwapBuffers; qSwapBuffers = SwapBuffers;
qGetDeviceGammaRamp = (void *)getglfunc("wglGetDeviceGammaRamp3DFX");
qSetDeviceGammaRamp = (void *)getglfunc("wglSetDeviceGammaRamp3DFX");
if (!qGetDeviceGammaRamp) qGetDeviceGammaRamp = (void*)GetDeviceGammaRamp;
if (!qSetDeviceGammaRamp) qSetDeviceGammaRamp = (void*)SetDeviceGammaRamp;
TRACE(("dbg: GLInitialise: got wgl funcs\n")); TRACE(("dbg: GLInitialise: got wgl funcs\n"));
return true; return true;
@ -631,16 +639,6 @@ int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
vid.recalc_refdef = 1; vid.recalc_refdef = 1;
maindc = GetDC(mainwindow);
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")); TRACE(("dbg: GLVID_SetMode: attaching gl\n"));
if (!VID_AttachGL(info)) if (!VID_AttachGL(info))
{ {
@ -648,6 +646,17 @@ int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
return false; return false;
} }
TRACE(("dbg: GLVID_SetMode: attaching gl okay\n")); TRACE(("dbg: GLVID_SetMode: attaching gl okay\n"));
maindc = GetDC(mainwindow);
if (vid_desktopgamma.value)
{
HDC hDC = GetDC(GetDesktopWindow());
gammaworks = qGetDeviceGammaRamp(hDC, originalgammaramps);
ReleaseDC(GetDesktopWindow(), hDC);
}
else
gammaworks = qGetDeviceGammaRamp(maindc, originalgammaramps);
return true; return true;
} }
@ -948,11 +957,13 @@ void GLVID_ShiftPalette (unsigned char *palette)
if (vid_desktopgamma.value) if (vid_desktopgamma.value)
{ {
HDC hDC = GetDC(GetDesktopWindow()); HDC hDC = GetDC(GetDesktopWindow());
gammaworks = SetDeviceGammaRamp (hDC, ramps); gammaworks = qSetDeviceGammaRamp (hDC, ramps);
ReleaseDC(GetDesktopWindow(), hDC); ReleaseDC(GetDesktopWindow(), hDC);
} }
else else
gammaworks = SetDeviceGammaRamp (maindc, ramps); {
gammaworks = qSetDeviceGammaRamp (maindc, ramps);
}
return; return;
} }
} }
@ -967,14 +978,21 @@ void VID_SetDefaultMode (void)
void GLVID_Shutdown (void) void GLVID_Shutdown (void)
{ {
if (vid_desktopgamma.value) if (qSetDeviceGammaRamp)
{ {
HDC hDC = GetDC(GetDesktopWindow()); if (vid_desktopgamma.value)
SetDeviceGammaRamp(hDC, originalgammaramps); {
ReleaseDC(GetDesktopWindow(), hDC); HDC hDC = GetDC(GetDesktopWindow());
qSetDeviceGammaRamp(hDC, originalgammaramps);
ReleaseDC(GetDesktopWindow(), hDC);
}
else
{
qSetDeviceGammaRamp(maindc, originalgammaramps);
}
} }
else qSetDeviceGammaRamp = NULL;
SetDeviceGammaRamp(maindc, originalgammaramps); qGetDeviceGammaRamp = NULL;
gammaworks = false; gammaworks = false;
@ -1143,14 +1161,19 @@ qboolean GLAppActivate(BOOL fActive, BOOL minimize)
v_gamma.modified = true; //wham bam thanks. v_gamma.modified = true; //wham bam thanks.
if (vid_desktopgamma.value) if (qSetDeviceGammaRamp)
{ {
HDC hDC = GetDC(GetDesktopWindow()); if (vid_desktopgamma.value)
gammaworks = SetDeviceGammaRamp (hDC, originalgammaramps); {
ReleaseDC(GetDesktopWindow(), hDC); HDC hDC = GetDC(GetDesktopWindow());
gammaworks = qSetDeviceGammaRamp (hDC, originalgammaramps);
ReleaseDC(GetDesktopWindow(), hDC);
}
else
{
gammaworks = qSetDeviceGammaRamp(maindc, originalgammaramps);
}
} }
else
gammaworks = SetDeviceGammaRamp(maindc, originalgammaramps);
} }
vid_hardwaregamma.modified = true; vid_hardwaregamma.modified = true;