- removed the direct setters for the blend mode state.

This will now always have to go through the render state.
This commit is contained in:
Christoph Oelckers 2018-10-21 14:26:14 +02:00
parent a3aaa5cc8b
commit 0af65a8fa0
6 changed files with 10 additions and 25 deletions

View file

@ -537,8 +537,7 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer)
} }
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.SetRenderStyle(STYLE_Translucent);
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gl_RenderState.SetVertexBuffer(mVBO); gl_RenderState.SetVertexBuffer(mVBO);
gl_RenderState.EnableTexture(true); gl_RenderState.EnableTexture(true);
gl_RenderState.EnableBrightmap(true); gl_RenderState.EnableBrightmap(true);

View file

@ -143,18 +143,6 @@ public:
mClipSplit[1] = 1000000.f; mClipSplit[1] = 1000000.f;
} }
void BlendFunc(int src, int dst)
{
glBlendFunc(src, dst);
stRenderStyle = LegacyRenderStyles[STYLE_OptFuzzy]; // temporary hack: Set to something that never can get here to invalidate the cache
}
void BlendEquation(int eq)
{
glBlendEquation(eq);
stRenderStyle = LegacyRenderStyles[STYLE_OptFuzzy]; // temporary hack: Set to something that never can get here to invalidate the cache
}
// This wraps the depth clamp setting because we frequently need to read it which OpenGL is not particularly performant at... // 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 SetDepthClamp(bool on)
{ {

View file

@ -302,8 +302,7 @@ void GLPortal::End(HWDrawInfo *di, bool usestencil)
glColorMask(0, 0, 0, 1); // mark portal in alpha channel but don't touch color glColorMask(0, 0, 0, 1); // mark portal in alpha channel but don't touch color
gl_RenderState.SetEffect(EFF_STENCIL); gl_RenderState.SetEffect(EFF_STENCIL);
gl_RenderState.EnableTexture(false); gl_RenderState.EnableTexture(false);
gl_RenderState.BlendFunc(GL_ONE, GL_ZERO); gl_RenderState.SetRenderStyle(STYLE_Source);
gl_RenderState.BlendEquation(GL_FUNC_ADD);
gl_RenderState.Apply(); gl_RenderState.Apply();
DrawPortalStencil(STP_DepthRestore); DrawPortalStencil(STP_DepthRestore);
gl_RenderState.SetEffect(EFF_NONE); gl_RenderState.SetEffect(EFF_NONE);
@ -429,7 +428,7 @@ void GLHorizonPortal::DrawContents(HWDrawInfo *hwdi)
gl_RenderState.SetPlaneTextureRotation(sp, gltexture); gl_RenderState.SetPlaneTextureRotation(sp, gltexture);
gl_RenderState.AlphaFunc(Alpha_GEqual, 0.f); gl_RenderState.AlphaFunc(Alpha_GEqual, 0.f);
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); gl_RenderState.SetRenderStyle(STYLE_Source);
gl_RenderState.Apply(); gl_RenderState.Apply();

View file

@ -152,7 +152,7 @@ void FDrawInfo::RenderScene(int recursion)
if (!gl_no_skyclear) GLRenderer->mPortalState.RenderFirstSkyPortal(recursion, this); if (!gl_no_skyclear) GLRenderer->mPortalState.RenderFirstSkyPortal(recursion, this);
gl_RenderState.EnableFog(true); gl_RenderState.EnableFog(true);
gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); gl_RenderState.SetRenderStyle(STYLE_Source);
if (gl_sort_textures) if (gl_sort_textures)
{ {
@ -191,7 +191,7 @@ void FDrawInfo::RenderScene(int recursion)
drawlists[GLDL_MODELS].Draw(this, gl_RenderState, false, pass); drawlists[GLDL_MODELS].Draw(this, gl_RenderState, false, pass);
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.SetRenderStyle(STYLE_Translucent);
// Part 4: Draw decals (not a real pass) // Part 4: Draw decals (not a real pass)
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
@ -212,7 +212,7 @@ void FDrawInfo::RenderTranslucent()
// final pass: translucent stuff // final pass: translucent stuff
gl_RenderState.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold); gl_RenderState.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.SetRenderStyle(STYLE_Translucent);
gl_RenderState.EnableBrightmap(true); gl_RenderState.EnableBrightmap(true);
drawlists[GLDL_TRANSLUCENTBORDER].Draw(this, gl_RenderState, true, GLPASS_TRANSLUCENT); drawlists[GLDL_TRANSLUCENTBORDER].Draw(this, gl_RenderState, true, GLPASS_TRANSLUCENT);
@ -315,7 +315,7 @@ void FDrawInfo::EndDrawScene(sector_t * viewsector)
glViewport(screen->mScreenViewport.left, screen->mScreenViewport.top, screen->mScreenViewport.width, screen->mScreenViewport.height); glViewport(screen->mScreenViewport.left, screen->mScreenViewport.top, screen->mScreenViewport.width, screen->mScreenViewport.height);
// Restore standard rendering state // Restore standard rendering state
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.SetRenderStyle(STYLE_Translucent);
gl_RenderState.ResetColor(); gl_RenderState.ResetColor();
gl_RenderState.EnableTexture(true); gl_RenderState.EnableTexture(true);
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
@ -339,7 +339,7 @@ void FDrawInfo::DrawEndScene2D(sector_t * viewsector)
gl_RenderState.SetSoftLightLevel(-1); gl_RenderState.SetSoftLightLevel(-1);
// Restore standard rendering state // Restore standard rendering state
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.SetRenderStyle(STYLE_Translucent);
gl_RenderState.ResetColor(); gl_RenderState.ResetColor();
gl_RenderState.EnableTexture(true); gl_RenderState.EnableTexture(true);
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);

View file

@ -226,7 +226,7 @@ void GLSkyPortal::DrawContents(HWDrawInfo *di)
gl_RenderState.ResetColor(); gl_RenderState.ResetColor();
gl_RenderState.EnableFog(false); gl_RenderState.EnableFog(false);
gl_RenderState.AlphaFunc(Alpha_GEqual, 0.f); gl_RenderState.AlphaFunc(Alpha_GEqual, 0.f);
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_RenderState.SetRenderStyle(STYLE_Translucent);
bool oldClamp = gl_RenderState.SetDepthClamp(true); bool oldClamp = gl_RenderState.SetDepthClamp(true);
di->SetupView(0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1)); di->SetupView(0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1));

View file

@ -253,8 +253,7 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
// If we get here we know that we have colored fog and no fixed colormap. // If we get here we know that we have colored fog and no fixed colormap.
SetFog(sprite->foglevel, rel, &sprite->Colormap, additivefog); SetFog(sprite->foglevel, rel, &sprite->Colormap, additivefog);
gl_RenderState.SetTextureMode(TM_FOGLAYER); gl_RenderState.SetTextureMode(TM_FOGLAYER);
gl_RenderState.BlendEquation(GL_FUNC_ADD); gl_RenderState.SetRenderStyle(STYLE_Translucent);
gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
gl_RenderState.Apply(); gl_RenderState.Apply();
glDrawArrays(GL_TRIANGLE_STRIP, sprite->vertexindex, 4); glDrawArrays(GL_TRIANGLE_STRIP, sprite->vertexindex, 4);
gl_RenderState.SetTextureMode(TM_NORMAL); gl_RenderState.SetTextureMode(TM_NORMAL);