From aeef86dc625f42fab1e475efccec2387d6d03650 Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 9 Jan 2008 00:37:17 +0000 Subject: [PATCH] New cvar, vid_preservegamma. Set it to 0 to obliterate your old gamma settings when you leave FTE. This mimics the use of quake3 to reset your gamma settings should FTE crash on you. The default is to restore gamma settings to how they were when you first loaded FTE, the same as before. You can now use FTE to reset your gamma if FTE crashed and broke it. Only applies to the windows version so far. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2850 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/renderer.c | 2 ++ engine/gl/gl_vidnt.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/engine/client/renderer.c b/engine/client/renderer.c index e8a79d00d..4471a7ad2 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -344,6 +344,7 @@ cvar_t r_shadows = SCVARF ("r_shadows", "0", CVAR_ARCHIVE | CVAR_RENDERERLATCH); cvar_t r_vertexdlights = SCVAR ("r_vertexdlights", "1"); +cvar_t vid_preservegamma = SCVAR ("vid_preservegamma", "1"); cvar_t vid_hardwaregamma = SCVARF ("vid_hardwaregamma", "1", CVAR_ARCHIVE | CVAR_RENDERERLATCH); cvar_t vid_desktopgamma = SCVARF ("vid_desktopgamma", "0", @@ -370,6 +371,7 @@ void GLRenderer_Init(void) //screen Cvar_Register (&gl_triplebuffer, GLRENDEREROPTIONS); + Cvar_Register (&vid_preservegamma, GLRENDEREROPTIONS); Cvar_Register (&vid_hardwaregamma, GLRENDEREROPTIONS); Cvar_Register (&vid_desktopgamma, GLRENDEREROPTIONS); diff --git a/engine/gl/gl_vidnt.c b/engine/gl/gl_vidnt.c index 8c26964a1..0f8ad0bda 100644 --- a/engine/gl/gl_vidnt.c +++ b/engine/gl/gl_vidnt.c @@ -145,6 +145,7 @@ extern cvar_t _windowed_mouse; extern cvar_t vid_hardwaregamma; extern cvar_t vid_desktopgamma; extern cvar_t gl_lateswap; +extern cvar_t vid_preservegamma; int window_center_x, window_center_y, window_x, window_y, window_width, window_height; RECT window_rect; @@ -932,6 +933,20 @@ void GL_EndRendering (void) GL_DoSwap(); } +void OblitterateOldGamma(void) +{ + int i; + if (vid_preservegamma.value) + return; + + for (i = 0; i < 256; i++) + { + originalgammaramps[0][i] = (i<<8) + i; + originalgammaramps[1][i] = (i<<8) + i; + originalgammaramps[2][i] = (i<<8) + i; + } +} + void GLVID_SetPalette (unsigned char *palette) { qbyte *pal; @@ -1020,6 +1035,8 @@ void GLVID_Shutdown (void) { if (qSetDeviceGammaRamp) { + OblitterateOldGamma(); + if (vid_desktopgamma.value) { HDC hDC = GetDC(GetDesktopWindow()); @@ -1333,6 +1350,8 @@ qboolean GLAppActivate(BOOL fActive, BOOL minimize) if (qSetDeviceGammaRamp) { + OblitterateOldGamma(); + if (vid_desktopgamma.value) { HDC hDC = GetDC(GetDesktopWindow());