From 61c94c25ed7e87c6f06f0dceda8f4d7d191e0017 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 26 Apr 2020 10:58:44 +0200 Subject: [PATCH] - more hw_cvars cleanup. Copied several range checks from Raze, moved vid_gamma to hw_cvars.cpp and removed some old and no longer necessary gamma setup code. --- src/r_data/v_palette.cpp | 41 ----------------- src/rendering/hwrenderer/utility/hw_cvars.cpp | 45 ++++++++++++++++--- src/rendering/v_video.cpp | 2 - src/rendering/v_video.h | 2 - 4 files changed, 39 insertions(+), 51 deletions(-) diff --git a/src/r_data/v_palette.cpp b/src/r_data/v_palette.cpp index 1b007099b..795580be6 100644 --- a/src/r_data/v_palette.cpp +++ b/src/r_data/v_palette.cpp @@ -34,12 +34,6 @@ #include "g_level.h" -#ifdef _WIN32 -#include -#else -#define O_BINARY 0 -#endif - #include "templates.h" #include "v_video.h" #include "filesystem.h" @@ -54,39 +48,6 @@ /* Current color blending values */ int BlendR, BlendG, BlendB, BlendA; -/**************************/ -/* Gamma correction stuff */ -/**************************/ - -uint8_t newgamma[256]; -CUSTOM_CVAR (Float, vid_gamma, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -{ - if (self == 0.f) - { // Gamma values of 0 are illegal. - self = 1.f; - return; - } - - if (screen != NULL) - { - screen->SetGamma (); - } -} - -CCMD (bumpgamma) -{ - // [RH] Gamma correction tables are now generated on the fly for *any* gamma level - // Q: What are reasonable limits to use here? - - float newgamma = vid_gamma + 0.1f; - - if (newgamma > 3.0) - newgamma = 1.0; - - vid_gamma = newgamma; - Printf ("Gamma correction level %g\n", *vid_gamma); -} - void InitPalette () @@ -103,8 +64,6 @@ void InitPalette () if (lump != -1) { FileData cmap = fileSystem.ReadFile(lump); - uint8_t palbuffer[768]; - ReadPalette(fileSystem.GetNumForName("PLAYPAL"), palbuffer); const unsigned char* cmapdata = (const unsigned char*)cmap.GetMem(); GPalette.GenerateGlobalBrightmapFromColormap(cmapdata, 32); } diff --git a/src/rendering/hwrenderer/utility/hw_cvars.cpp b/src/rendering/hwrenderer/utility/hw_cvars.cpp index 42b5ddacd..d0a4c19e9 100644 --- a/src/rendering/hwrenderer/utility/hw_cvars.cpp +++ b/src/rendering/hwrenderer/utility/hw_cvars.cpp @@ -40,16 +40,13 @@ #include "c_dispatch.h" #include "v_video.h" #include "hw_cvars.h" -#include "hw_material.h" #include "menu/menu.h" -#include "texturemanager.h" // OpenGL stuff moved here // GL related CVARs CVAR(Bool, gl_portals, true, 0) -CVAR(Bool, gl_noquery, false, 0) CVAR(Bool,gl_mirrors,true,0) // This is for debugging only! CVAR(Bool,gl_mirror_envmap, true, CVAR_GLOBALCONFIG|CVAR_ARCHIVE) CVAR(Bool, gl_seamless, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) @@ -70,9 +67,45 @@ CUSTOM_CVAR(Bool, gl_render_precise, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) gl_seamless=self; } -CVAR (Float, vid_brightness, 0.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR (Float, vid_contrast, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -CVAR (Float, vid_saturation, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) +CUSTOM_CVARD(Float, vid_gamma, 1.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "adjusts gamma component of gamma ramp") +{ + if (self < 0) self = 1; + else if (self > 4) self = 4; +} + +CUSTOM_CVARD(Float, vid_contrast, 1.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "adjusts contrast component of gamma ramp") +{ + if (self < 0) self = 0; + else if (self > 5) self = 5; +} + +CUSTOM_CVARD(Float, vid_brightness, 0.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "adjusts brightness component of gamma ramp") +{ + if (self < -2) self = -2; + else if (self > 2) self = 2; +} + +CUSTOM_CVARD(Float, vid_saturation, 1.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG, "adjusts saturation component of gamma ramp") +{ + if (self < -3) self = -3; + else if (self > 3) self = 3; +} + +CCMD (bumpgamma) +{ + // [RH] Gamma correction tables are now generated on the fly for *any* gamma level + // Q: What are reasonable limits to use here? + + float newgamma = vid_gamma + 0.1f; + + if (newgamma > 4.0) + newgamma = 1.0; + + vid_gamma = newgamma; + Printf ("Gamma correction level %g\n", newgamma); +} + + CVAR(Int, gl_satformula, 1, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); //========================================================================== diff --git a/src/rendering/v_video.cpp b/src/rendering/v_video.cpp index 958486e30..ff6564629 100644 --- a/src/rendering/v_video.cpp +++ b/src/rendering/v_video.cpp @@ -347,7 +347,6 @@ bool IVideo::SetResolution () screen = buff; screen->InitializeState(); - screen->SetGamma(); V_UpdateModeSize(screen->GetWidth(), screen->GetHeight()); @@ -423,7 +422,6 @@ void V_Init2() menu_resolution_custom_height = SCREENHEIGHT; screen->SetVSync(vid_vsync); - screen->SetGamma (); FBaseCVar::ResetColors (); C_NewModeAdjust(); setsizeneeded = true; diff --git a/src/rendering/v_video.h b/src/rendering/v_video.h index 0fa592ff3..e790d7227 100644 --- a/src/rendering/v_video.h +++ b/src/rendering/v_video.h @@ -215,8 +215,6 @@ public: // Mark the palette as changed. It will be updated on the next Update(). virtual void UpdatePalette() {} - virtual void SetGamma() {} - // Returns true if running fullscreen. virtual bool IsFullscreen () = 0; virtual void ToggleFullscreen(bool yes) {}