mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-28 14:42:23 +00:00
- fixed: The depth clamp setting needs to be tracked per portal so that it can be properly restored afterward.
Regular skies need it off but SkyViewpoints need it on - and all others need to use the parent's setting. So without engine side tracking we can end up rendering the sky with this setting off, resulting in omission of the fog layer.
This commit is contained in:
parent
eb753a0b7c
commit
ec627d94dd
4 changed files with 16 additions and 3 deletions
|
@ -90,6 +90,7 @@ void FRenderState::Reset()
|
||||||
stSrcBlend = stDstBlend = -1;
|
stSrcBlend = stDstBlend = -1;
|
||||||
stBlendEquation = -1;
|
stBlendEquation = -1;
|
||||||
stAlphaThreshold = -1.f;
|
stAlphaThreshold = -1.f;
|
||||||
|
mLastDepthClamp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -63,6 +63,7 @@ class FRenderState
|
||||||
float mInterpolationFactor;
|
float mInterpolationFactor;
|
||||||
float mClipHeightTop, mClipHeightBottom;
|
float mClipHeightTop, mClipHeightBottom;
|
||||||
float mShaderTimer;
|
float mShaderTimer;
|
||||||
|
bool mLastDepthClamp;
|
||||||
|
|
||||||
FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer;
|
FVertexBuffer *mVertexBuffer, *mCurrentVertexBuffer;
|
||||||
FStateVec4 mColor;
|
FStateVec4 mColor;
|
||||||
|
@ -309,6 +310,16 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This wraps the depth clamp setting because we frequently need to read it which OpenGL is not particularly performant at...
|
||||||
|
bool SetDepthClamp(bool on)
|
||||||
|
{
|
||||||
|
bool res = mLastDepthClamp;
|
||||||
|
if (!on) glDisable(GL_DEPTH_CLAMP);
|
||||||
|
else glEnable(GL_DEPTH_CLAMP);
|
||||||
|
mLastDepthClamp = on;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
void Set2DMode(bool on)
|
void Set2DMode(bool on)
|
||||||
{
|
{
|
||||||
m2D = on;
|
m2D = on;
|
||||||
|
|
|
@ -633,8 +633,7 @@ void GLSkyboxPortal::DrawContents()
|
||||||
|
|
||||||
PlaneMirrorMode=0;
|
PlaneMirrorMode=0;
|
||||||
|
|
||||||
glDisable(GL_DEPTH_CLAMP);
|
bool oldclamp = gl_RenderState.SetDepthClamp(false);
|
||||||
|
|
||||||
viewx = origin->PrevX + FixedMul(r_TicFrac, origin->x - origin->PrevX);
|
viewx = origin->PrevX + FixedMul(r_TicFrac, origin->x - origin->PrevX);
|
||||||
viewy = origin->PrevY + FixedMul(r_TicFrac, origin->y - origin->PrevY);
|
viewy = origin->PrevY + FixedMul(r_TicFrac, origin->y - origin->PrevY);
|
||||||
viewz = origin->PrevZ + FixedMul(r_TicFrac, origin->z - origin->PrevZ);
|
viewz = origin->PrevZ + FixedMul(r_TicFrac, origin->z - origin->PrevZ);
|
||||||
|
@ -663,7 +662,7 @@ void GLSkyboxPortal::DrawContents()
|
||||||
GLRenderer->DrawScene();
|
GLRenderer->DrawScene();
|
||||||
origin->flags&=~MF_JUSTHIT;
|
origin->flags&=~MF_JUSTHIT;
|
||||||
inskybox=false;
|
inskybox=false;
|
||||||
glEnable(GL_DEPTH_CLAMP);
|
gl_RenderState.SetDepthClamp(oldclamp);
|
||||||
skyboxrecursion--;
|
skyboxrecursion--;
|
||||||
|
|
||||||
PlaneMirrorMode=old_pm;
|
PlaneMirrorMode=old_pm;
|
||||||
|
|
|
@ -475,6 +475,7 @@ void GLSkyPortal::DrawContents()
|
||||||
gl_RenderState.EnableFog(false);
|
gl_RenderState.EnableFog(false);
|
||||||
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
gl_RenderState.AlphaFunc(GL_GEQUAL, 0.f);
|
||||||
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
bool oldClamp = gl_RenderState.SetDepthClamp(true);
|
||||||
|
|
||||||
gl_MatrixStack.Push(gl_RenderState.mViewMatrix);
|
gl_MatrixStack.Push(gl_RenderState.mViewMatrix);
|
||||||
GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
GLRenderer->SetupView(0, 0, 0, viewangle, !!(MirrorFlag&1), !!(PlaneMirrorFlag&1));
|
||||||
|
@ -519,5 +520,6 @@ void GLSkyPortal::DrawContents()
|
||||||
gl_MatrixStack.Pop(gl_RenderState.mViewMatrix);
|
gl_MatrixStack.Pop(gl_RenderState.mViewMatrix);
|
||||||
gl_RenderState.ApplyMatrices();
|
gl_RenderState.ApplyMatrices();
|
||||||
glset.lightmode = oldlightmode;
|
glset.lightmode = oldlightmode;
|
||||||
|
gl_RenderState.SetDepthClamp(oldClamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue