From 0af65a8fa0a7224ade56d2a37874b7d10344d66e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 21 Oct 2018 14:26:14 +0200 Subject: [PATCH] - removed the direct setters for the blend mode state. This will now always have to go through the render state. --- src/gl/renderer/gl_renderer.cpp | 3 +-- src/gl/renderer/gl_renderstate.h | 12 ------------ src/gl/scene/gl_portal.cpp | 5 ++--- src/gl/scene/gl_scene.cpp | 10 +++++----- src/gl/scene/gl_skydome.cpp | 2 +- src/gl/scene/gl_sprite.cpp | 3 +-- 6 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index a119ec489..b9d47bbb4 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -537,8 +537,7 @@ void FGLRenderer::Draw2D(F2DDrawer *drawer) } glDisable(GL_SCISSOR_TEST); - gl_RenderState.BlendEquation(GL_FUNC_ADD); - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.SetRenderStyle(STYLE_Translucent); gl_RenderState.SetVertexBuffer(mVBO); gl_RenderState.EnableTexture(true); gl_RenderState.EnableBrightmap(true); diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index 83b90b905..6d651b11e 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -143,18 +143,6 @@ public: 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... bool SetDepthClamp(bool on) { diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index 2d27e5cf2..9f96dea28 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -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 gl_RenderState.SetEffect(EFF_STENCIL); gl_RenderState.EnableTexture(false); - gl_RenderState.BlendFunc(GL_ONE, GL_ZERO); - gl_RenderState.BlendEquation(GL_FUNC_ADD); + gl_RenderState.SetRenderStyle(STYLE_Source); gl_RenderState.Apply(); DrawPortalStencil(STP_DepthRestore); gl_RenderState.SetEffect(EFF_NONE); @@ -429,7 +428,7 @@ void GLHorizonPortal::DrawContents(HWDrawInfo *hwdi) gl_RenderState.SetPlaneTextureRotation(sp, gltexture); gl_RenderState.AlphaFunc(Alpha_GEqual, 0.f); - gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); + gl_RenderState.SetRenderStyle(STYLE_Source); gl_RenderState.Apply(); diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 0c07ab8e3..71893795c 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -152,7 +152,7 @@ void FDrawInfo::RenderScene(int recursion) if (!gl_no_skyclear) GLRenderer->mPortalState.RenderFirstSkyPortal(recursion, this); gl_RenderState.EnableFog(true); - gl_RenderState.BlendFunc(GL_ONE,GL_ZERO); + gl_RenderState.SetRenderStyle(STYLE_Source); if (gl_sort_textures) { @@ -191,7 +191,7 @@ void FDrawInfo::RenderScene(int recursion) 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) glDepthFunc(GL_LEQUAL); @@ -212,7 +212,7 @@ void FDrawInfo::RenderTranslucent() // final pass: translucent stuff 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); 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); // 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.EnableTexture(true); glDisable(GL_SCISSOR_TEST); @@ -339,7 +339,7 @@ void FDrawInfo::DrawEndScene2D(sector_t * viewsector) gl_RenderState.SetSoftLightLevel(-1); // 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.EnableTexture(true); glDisable(GL_SCISSOR_TEST); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index cc921ddbc..468a82574 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -226,7 +226,7 @@ void GLSkyPortal::DrawContents(HWDrawInfo *di) gl_RenderState.ResetColor(); gl_RenderState.EnableFog(false); 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); di->SetupView(0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1)); diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 6823feccf..94304c535 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -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. SetFog(sprite->foglevel, rel, &sprite->Colormap, additivefog); gl_RenderState.SetTextureMode(TM_FOGLAYER); - gl_RenderState.BlendEquation(GL_FUNC_ADD); - gl_RenderState.BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + gl_RenderState.SetRenderStyle(STYLE_Translucent); gl_RenderState.Apply(); glDrawArrays(GL_TRIANGLE_STRIP, sprite->vertexindex, 4); gl_RenderState.SetTextureMode(TM_NORMAL);