Skip to content

Commit 11544d8

Browse files
past-duepull[bot]
authored andcommitted
Fix: Initializing depth pass properties when starting with shadows disabled
Always call pie_setShadowMode() on init
1 parent 694a654 commit 11544d8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/ivis_opengl/piedraw.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static size_t pieCount = 0;
6666
static size_t polyCount = 0;
6767
static size_t drawCallsCount = 0;
6868
static bool shadows = false;
69+
static bool shadowsHasBeenInit = false;
6970
static ShadowMode shadowMode = ShadowMode::Shadow_Mapping;
7071
static gfx_api::gfxFloat lighting0[LIGHT_MAX][4];
7172
static gfx_api::gfxFloat lightingDefault[LIGHT_MAX][4];
@@ -161,7 +162,7 @@ uint32_t pie_getShadowMapResolution()
161162

162163
bool pie_setShadowMode(ShadowMode mode)
163164
{
164-
if (mode == shadowMode)
165+
if (mode == shadowMode && shadowsHasBeenInit)
165166
{
166167
return true;
167168
}
@@ -179,6 +180,7 @@ bool pie_setShadowMode(ShadowMode mode)
179180
}
180181
shadowMode = mode;
181182
refreshShadowShaders();
183+
shadowsHasBeenInit = true;
182184
return successfulChangeToInputMode;
183185
}
184186

lib/ivis_opengl/piestate.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ bool pie_LoadShaders(uint32_t shadowFilterSize)
124124
// note: actual loading of shaders now occurs in gfx_api
125125

126126
// initialize gfx context shadow constants (must happen after context is initialized)
127+
ASSERT(gfx_api::context::isInitialized(), "gfx context isn't initialized?");
127128
auto shadowConstants = gfx_api::context::get().getShadowConstants();
128129
shadowConstants.shadowFilterSize = shadowFilterSize;
129130
gfx_api::context::get().setShadowConstants(shadowConstants);
@@ -132,6 +133,10 @@ bool pie_LoadShaders(uint32_t shadowFilterSize)
132133
{
133134
pie_setShadowMode(ShadowMode::Fallback_Stencil_Shadows);
134135
}
136+
else
137+
{
138+
pie_setShadowMode(ShadowMode::Shadow_Mapping);
139+
}
135140

136141
gfx_api::gfxUByte rect[] {
137142
0, 255, 0, 255,

0 commit comments

Comments
 (0)