Skip to content

Commit

Permalink
- fix gl_lightmode migration
Browse files Browse the repository at this point in the history
Use a new CVAR to evade the clamp-on-write that destroys the original value and use a more robust method to set the new value.

Fixes #2117
  • Loading branch information
prof-hastig committed Sep 14, 2023
1 parent 52ec2b2 commit c215293
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/g_level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ CUSTOM_CVAR(Int, gl_maplightmode, -1, CVAR_NOINITCALL) // this is just for testi
if (self > 5 || self < -1) self = -1;
}

CUSTOM_CVAR(Int, gl_lightmode, 1, CVAR_ARCHIVE | CVAR_NOINITCALL)
CUSTOM_CVAR(Int, hw_lightmode, 1, CVAR_ARCHIVE | CVAR_NOINITCALL)
{
if (self < 0 || self > 2) self = 2;
}
Expand All @@ -166,8 +166,8 @@ ELightMode getRealLightmode(FLevelLocals* Level, bool for3d)
}
if (lightmode == ELightMode::Doom && for3d)
{
if (gl_lightmode == 1) lightmode = ELightMode::ZDoomSoftware;
else if (gl_lightmode == 2) lightmode = ELightMode::DoomSoftware;
if (hw_lightmode == 1) lightmode = ELightMode::ZDoomSoftware;
else if (hw_lightmode == 2) lightmode = ELightMode::DoomSoftware;
}
return lightmode;
}
Expand Down
7 changes: 4 additions & 3 deletions src/gameconfigfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,14 @@ void FGameConfigFile::DoGlobalSetup ()
var->SetGenericRep(v, CVAR_Float);
}
}
if (last < 225)
if (last < 226)
{
if (const auto var = FindCVar("gl_lightmode", NULL))
{
UCVarValue v = var->GetGenericRep(CVAR_Int);
v.Int /= 8; // all legacy modes map to 0, ZDoom software to 1 and Vanilla software to 2.
var->SetGenericRep(v, CVAR_Int);
if (last < 225) v.Int = v.Int == 16 ? 2 : v.Int == 8 ? 1 : 0;
auto newvar = FindCVar("hw_lightmode", NULL);
if (newvar != nullptr) newvar->SetGenericRep(v.Int, CVAR_Int);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/rendering/hwrenderer/scene/hw_lighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ PalEntry HWDrawInfo::CalcLightColor(int light, PalEntry pe, int blendfactor)
//
// Rules for fog:
//
// 1. If bit 4 of gl_lightmode is set always use the level's fog density.
// This is what Legacy's GL render does.
// 1. If lightmode is DoomLegacy, always use the level's fog density.
// 2. black fog means no fog and always uses the distfogtable based on the level's fog density setting
// 3. If outside fog is defined and the current fog color is the same as the outside fog
// the engine always uses the outside fog density to make the fog uniform across the Level->
Expand Down
2 changes: 1 addition & 1 deletion wadsrc/static/menudef.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2615,7 +2615,7 @@ OptionMenu "OpenGLOptions" protected
Submenu "$GLPREFMNU_VRMODE", "VR3DMenu"
Submenu "$GLMNU_POSTPROCESS", "PostProcessMenu"
StaticText " "
Option "$GLPREFMNU_SECLIGHTMODE", gl_lightmode, "LightingModes"
Option "$GLPREFMNU_SECLIGHTMODE", hw_lightmode, "LightingModes"
Option "$GLPREFMNU_SWLMBANDED", gl_bandedswlight, "OnOff"
Option "$GLPREFMNU_FOGMODE", gl_fogmode, "FogMode"
Option "$GLPREFMNU_FOGFORCEFULLBRIGHT", gl_brightfog, "YesNo"
Expand Down
2 changes: 1 addition & 1 deletion wadsrc/static/menudef.zsimple
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ OptionMenu VideoOptionsSimple protected
StaticText " "
Option "$GLTEXMNU_TEXFILTER", gl_texture_filter, "FilterModes"
Option "$GLTEXMNU_ANISOTROPIC", gl_texture_filter_anisotropic, "Anisotropy"
Option "$GLPREFMNU_SECLIGHTMODE", gl_lightmode, "LightingModes"
Option "$GLPREFMNU_SECLIGHTMODE", hw_lightmode, "LightingModes"
StaticText " "
Option "$DSPLYMNU_VSYNC", "vid_vsync", "OnOff"
Slider "$VIDMNU_MAXFPS", "vid_maxfps", 35, 500, 1
Expand Down

0 comments on commit c215293

Please sign in to comment.