Skip to content

Commit

Permalink
Fix: Initializing depth pass properties when starting with shadows di…
Browse files Browse the repository at this point in the history
…sabled

Always call pie_setShadowMode() on init
  • Loading branch information
past-due committed Oct 31, 2023
1 parent 24e1a81 commit fb6cbb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ivis_opengl/piedraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static size_t pieCount = 0;
static size_t polyCount = 0;
static size_t drawCallsCount = 0;
static bool shadows = false;
static bool shadowsHasBeenInit = false;
static ShadowMode shadowMode = ShadowMode::Shadow_Mapping;
static gfx_api::gfxFloat lighting0[LIGHT_MAX][4];
static gfx_api::gfxFloat lightingDefault[LIGHT_MAX][4];
Expand Down Expand Up @@ -161,7 +162,7 @@ uint32_t pie_getShadowMapResolution()

bool pie_setShadowMode(ShadowMode mode)
{
if (mode == shadowMode)
if (mode == shadowMode && shadowsHasBeenInit)
{
return true;
}
Expand All @@ -179,6 +180,7 @@ bool pie_setShadowMode(ShadowMode mode)
}
shadowMode = mode;
refreshShadowShaders();
shadowsHasBeenInit = true;
return successfulChangeToInputMode;
}

Expand Down
5 changes: 5 additions & 0 deletions lib/ivis_opengl/piestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ bool pie_LoadShaders(uint32_t shadowFilterSize)
// note: actual loading of shaders now occurs in gfx_api

// initialize gfx context shadow constants (must happen after context is initialized)
ASSERT(gfx_api::context::isInitialized(), "gfx context isn't initialized?");
auto shadowConstants = gfx_api::context::get().getShadowConstants();
shadowConstants.shadowFilterSize = shadowFilterSize;
gfx_api::context::get().setShadowConstants(shadowConstants);
Expand All @@ -132,6 +133,10 @@ bool pie_LoadShaders(uint32_t shadowFilterSize)
{
pie_setShadowMode(ShadowMode::Fallback_Stencil_Shadows);
}
else
{
pie_setShadowMode(ShadowMode::Shadow_Mapping);
}

gfx_api::gfxUByte rect[] {
0, 255, 0, 255,
Expand Down

0 comments on commit fb6cbb2

Please sign in to comment.