- 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.
This commit is contained in:
Christoph Oelckers 2020-04-26 10:58:44 +02:00
parent 1ad2f30e0d
commit 61c94c25ed
4 changed files with 39 additions and 51 deletions

View file

@ -34,12 +34,6 @@
#include "g_level.h"
#ifdef _WIN32
#include <io.h>
#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);
}

View file

@ -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);
//==========================================================================

View file

@ -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;

View file

@ -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) {}