Skip to content
Permalink
Browse files

- Fixed compilation of "- changed the stencil cap drawer to only cove…

…r the area which is actually used by the portal.".
  • Loading branch information...
drfrag666 committed Dec 10, 2018
1 parent de78923 commit ca71f82154cb3b9388e690a8215324287c0f70f0
Showing with 32 additions and 24 deletions.
  1. +31 −23 src/gl/scene/gl_portal.cpp
  2. +1 −1 src/gl/scene/gl_portal.h
@@ -124,7 +124,7 @@ void GLPortal::ClearScreen()
// DrawPortalStencil
//
//-----------------------------------------------------------------------------
void GLPortal::DrawPortalStencil(int pass)
void GLPortal::DrawPortalStencil(FDrawInfo *di, int pass)
{
if (mPrimIndices.Size() == 0)
{
@@ -146,25 +146,33 @@ void GLPortal::DrawPortalStencil(int pass)
if (pass == STP_AllInOne) glDepthMask(false);
else if (pass == STP_DepthRestore) glDepthRange(1, 1);

if (planesused & (1 << sector_t::floor))
if (di != nullptr)
{
auto verts = di->AllocVertices(4);
auto ptr = verts.first;
ptr[0].Set((float)boundingBox.Left(), -32767.f, (float)boundingBox.Top(), 0, 0);
ptr[1].Set((float)boundingBox.Right(), -32767.f, (float)boundingBox.Top(), 0, 0);
ptr[2].Set((float)boundingBox.Left(), -32767.f, (float)boundingBox.Bottom(), 0, 0);
ptr[3].Set((float)boundingBox.Right(), -32767.f, (float)boundingBox.Bottom(), 0, 0);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, verts.second, 4);
if (planesused & (1 << sector_t::floor))
{
auto verts = di->AllocVertices(4);
auto ptr = verts.first;
ptr[0].Set((float)boundingBox.Left(), -32767.f, (float)boundingBox.Top(), 0, 0);
ptr[1].Set((float)boundingBox.Right(), -32767.f, (float)boundingBox.Top(), 0, 0);
ptr[2].Set((float)boundingBox.Left(), -32767.f, (float)boundingBox.Bottom(), 0, 0);
ptr[3].Set((float)boundingBox.Right(), -32767.f, (float)boundingBox.Bottom(), 0, 0);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, verts.second, 4);
}
if (planesused & (1 << sector_t::ceiling))
{
auto verts = di->AllocVertices(4);
auto ptr = verts.first;
ptr[0].Set((float)boundingBox.Left(), 32767.f, (float)boundingBox.Top(), 0, 0);
ptr[1].Set((float)boundingBox.Right(), 32767.f, (float)boundingBox.Top(), 0, 0);
ptr[2].Set((float)boundingBox.Left(), 32767.f, (float)boundingBox.Bottom(), 0, 0);
ptr[3].Set((float)boundingBox.Right(), 32767.f, (float)boundingBox.Bottom(), 0, 0);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, verts.second, 4);
}
}
if (planesused & (1 << sector_t::ceiling))
else
{
auto verts = di->AllocVertices(4);
auto ptr = verts.first;
ptr[0].Set((float)boundingBox.Left(), 32767.f, (float)boundingBox.Top(), 0, 0);
ptr[1].Set((float)boundingBox.Right(), 32767.f, (float)boundingBox.Top(), 0, 0);
ptr[2].Set((float)boundingBox.Left(), 32767.f, (float)boundingBox.Bottom(), 0, 0);
ptr[3].Set((float)boundingBox.Right(), 32767.f, (float)boundingBox.Bottom(), 0, 0);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_STRIP, verts.second, 4);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILTOP_INDEX, 4);
GLRenderer->mVBO->RenderArray(GL_TRIANGLE_FAN, FFlatVertexBuffer::STENCILBOTTOM_INDEX, 4);
}
if (pass == STP_DepthRestore) glDepthRange(0, 1);
}
@@ -213,7 +221,7 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn
}
else doquery = false; // some kind of error happened

DrawPortalStencil(STP_Stencil);
DrawPortalStencil(outer_di, STP_Stencil);

glEndQuery(GL_SAMPLES_PASSED);

@@ -223,7 +231,7 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn
glDepthMask(true); // enable z-buffer again
glDepthRange(1, 1);
glDepthFunc(GL_ALWAYS);
DrawPortalStencil(STP_DepthClear);
DrawPortalStencil(outer_di, STP_DepthClear);

// set normal drawing mode
gl_RenderState.EnableTexture(true);
@@ -256,7 +264,7 @@ bool GLPortal::Start(bool usestencil, bool doquery, FDrawInfo *outer_di, FDrawIn
// Note: We must draw the stencil with z-write enabled here because there is no second pass!

glDepthMask(true);
DrawPortalStencil(STP_AllInOne);
DrawPortalStencil(outer_di, STP_AllInOne);
glStencilFunc(GL_EQUAL, recursion + 1, ~0); // draw sky into stencil
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // this stage doesn't modify the stencil
gl_RenderState.EnableTexture(true);
@@ -360,7 +368,7 @@ void GLPortal::End(bool usestencil)
// first step: reset the depth buffer to max. depth
glDepthRange(1, 1); // always
glDepthFunc(GL_ALWAYS); // write the farthest depth value
DrawPortalStencil(STP_DepthClear);
DrawPortalStencil(nullptr, STP_DepthClear);
}
else
{
@@ -372,7 +380,7 @@ void GLPortal::End(bool usestencil)
glDepthRange(0, 1);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
glStencilFunc(GL_EQUAL, recursion, ~0); // draw sky into stencil
DrawPortalStencil(STP_DepthRestore);
DrawPortalStencil(nullptr, STP_DepthRestore);
glDepthFunc(GL_LESS);


@@ -415,7 +423,7 @@ void GLPortal::End(bool usestencil)
gl_RenderState.BlendFunc(GL_ONE, GL_ZERO);
gl_RenderState.BlendEquation(GL_FUNC_ADD);
gl_RenderState.Apply();
DrawPortalStencil(STP_DepthRestore);
DrawPortalStencil(nullptr, STP_DepthRestore);
gl_RenderState.SetEffect(EFF_NONE);
gl_RenderState.EnableTexture(true);
}
@@ -80,7 +80,7 @@ class GLPortal : public IPortal
STP_DepthRestore,
STP_AllInOne
};
void DrawPortalStencil(int pass);
void DrawPortalStencil(FDrawInfo *di, int pass);

AActor * savedviewactor;
ActorRenderFlags savedvisibility;

0 comments on commit ca71f82

Please sign in to comment.
You can’t perform that action at this time.