- started with an abstract render interface, most importantly handle the stencil for plane flooding through the render state object instead of changing GL state directly.

This commit is contained in:
Christoph Oelckers 2018-10-20 21:08:24 +02:00
commit 3c3be0d349
7 changed files with 152 additions and 29 deletions

View file

@ -38,6 +38,8 @@
#include "gl/renderer/gl_renderbuffers.h"
#include "gl/textures/gl_hwtexture.h"
static int op2gl[] = { GL_KEEP, GL_INCR, GL_DECR };
FGLRenderState gl_RenderState;
CVAR(Bool, gl_direct_state_change, true, 0)
@ -226,6 +228,22 @@ void FGLRenderState::Apply()
}
}
if (mStencil.mChanged)
{
int recursion = GLRenderer->mPortalState.GetRecursion();
glStencilFunc(GL_EQUAL, recursion + mStencil.mOffsVal, ~0); // draw sky into stencil
glStencilOp(GL_KEEP, GL_KEEP, op2gl[mStencil.mOperation]); // this stage doesn't modify the stencil
bool cmon = !(mStencil.mFlags & SF_ColorMaskOff);
glColorMask(cmon, cmon, cmon, cmon); // don't write to the graphics buffer
glDepthMask(!(mStencil.mFlags & SF_DepthMaskOff));
if (mStencil.mFlags & SF_DepthTestOff)
glDisable(GL_DEPTH_TEST);
else
glEnable(GL_DEPTH_TEST);
}
if (mVertexBuffer != mCurrentVertexBuffer)
{
if (mVertexBuffer == NULL) glBindBuffer(GL_ARRAY_BUFFER, 0);