- removed two of the state flags in SetStencil and handle them explicitly.

This commit is contained in:
Christoph Oelckers 2018-10-29 09:53:07 +01:00
parent 163d6be0d7
commit 1bbc9f6730
5 changed files with 11 additions and 14 deletions

View File

@ -441,12 +441,6 @@ void FGLRenderState::SetStencil(int offs, int op, int flags)
bool cmon = !(flags & SF_ColorMaskOff);
glColorMask(cmon, cmon, cmon, cmon); // don't write to the graphics buffer
glDepthMask(!(flags & SF_DepthMaskOff));
if (flags & SF_DepthTestOff)
glDisable(GL_DEPTH_TEST);
else
glEnable(GL_DEPTH_TEST);
if (flags & SF_DepthClear)
glClear(GL_DEPTH_BUFFER_BIT);
}
void FGLRenderState::SetCulling(int mode)

View File

@ -99,7 +99,6 @@ public:
void Apply();
void ApplyBuffers();
void ApplyLightIndex(int index);
void ApplyBlendMode();
void ResetVertexBuffer()

View File

@ -39,8 +39,6 @@ enum EStencilFlags
SF_AllOn = 0,
SF_ColorMaskOff = 1,
SF_DepthMaskOff = 2,
SF_DepthTestOff = 4,
SF_DepthClear = 8
};
enum EStencilOp

View File

@ -255,17 +255,19 @@ void GLFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state)
// Draw projected plane into stencil
state.EnableTexture(true);
state.SetEffect(EFF_NONE);
state.SetStencil(1, SOP_Keep, SF_DepthMaskOff | SF_DepthTestOff);
state.SetStencil(1, SOP_Keep, SF_DepthMaskOff);
state.EnableDepthTest(false);
state.Draw(DT_TriangleFan,fnode->vertexindex + 4, 4);
// clear stencil
state.SetEffect(EFF_STENCIL);
state.EnableTexture(false);
state.SetStencil(1, SOP_Decrement, SF_ColorMaskOff | SF_DepthMaskOff | SF_DepthTestOff);
state.SetStencil(1, SOP_Decrement, SF_ColorMaskOff | SF_DepthMaskOff);
state.Draw(DT_TriangleFan,fnode->vertexindex, 4);
// restore old stencil op.
state.EnableTexture(true);
state.EnableDepthTest(true);
state.SetEffect(EFF_NONE);
state.SetDepthBias(0, 0);
state.SetStencil(0, SOP_Keep, SF_AllOn);

View File

@ -238,7 +238,8 @@ void HWPortal::SetupStencil(HWDrawInfo *di, FRenderState &state, bool usestencil
state.SetDepthFunc(DF_Less);
DrawPortalStencil(state, STP_AllInOne);
state.SetStencil(1, SOP_Keep, SF_DepthTestOff | SF_DepthMaskOff);
state.SetStencil(1, SOP_Keep, SF_DepthMaskOff);
state.EnableDepthTest(false);
state.EnableTexture(true);
state.SetEffect(EFF_NONE);
}
@ -249,7 +250,8 @@ void HWPortal::SetupStencil(HWDrawInfo *di, FRenderState &state, bool usestencil
{
if (!NeedDepthBuffer())
{
state.SetStencil(0, SOP_Keep, SF_DepthTestOff | SF_DepthMaskOff);
state.SetStencil(0, SOP_Keep, SF_DepthMaskOff);
state.EnableDepthTest(false);
}
}
@ -266,6 +268,7 @@ void HWPortal::RemoveStencil(HWDrawInfo *di, FRenderState &state, bool usestenci
auto &vp = di->Viewpoint;
if (vp.camera != nullptr) vp.camera->renderflags = (vp.camera->renderflags & ~RF_MAYBEINVISIBLE) | savedvisibility;
state.EnableDepthTest(true);
if (usestencil)
{
state.SetEffect(EFF_NONE);
@ -298,7 +301,8 @@ void HWPortal::RemoveStencil(HWDrawInfo *di, FRenderState &state, bool usestenci
state.EnableTexture(false);
state.SetRenderStyle(STYLE_Source);
state.SetStencil(0, SOP_Keep, needdepth ? SF_ColorMaskOff | SF_DepthClear : SF_ColorMaskOff);
state.SetStencil(0, SOP_Keep, SF_ColorMaskOff);
if (needdepth) state.Clear(CT_Depth);
state.SetDepthRange(0, 1);
state.SetDepthFunc(DF_LEqual);
DrawPortalStencil(state, STP_DepthRestore);