From 6c6874cb0e68442e5d7da8f26570048511a11be4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Jan 2020 10:21:34 +0100 Subject: [PATCH] - fixed scissoring with out of range coordinates. Blood's status bar sets such a bogus clipping rectangle. --- source/glbackend/gl_renderstate.h | 2 +- source/glbackend/glbackend.cpp | 2 +- source/glbackend/glbackend.h | 2 +- source/glbackend/hw_draw2d.cpp | 10 ++++------ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/source/glbackend/gl_renderstate.h b/source/glbackend/gl_renderstate.h index ddb706cc6..f113158a3 100644 --- a/source/glbackend/gl_renderstate.h +++ b/source/glbackend/gl_renderstate.h @@ -74,7 +74,7 @@ struct PolymostRenderState int DepthFunc = 1; PalEntry ClearColor = 0; short vp_x, vp_y, vp_w, vp_h; - short sc_x, sc_y, sc_w, sc_h; + short sc_x = SHRT_MIN, sc_y, sc_w, sc_h; int texIds[5], samplerIds[5]; PalEntry FogColor; diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index c8c2fb7a4..98903c44e 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -444,7 +444,7 @@ void PolymostRenderState::Apply(PolymostShader* shader, GLState &oldState) } if (StateFlags & STF_SCISSORSET) { - if (sc_x >= 0) + if (sc_x > SHRT_MIN) { glScissor(sc_x, sc_y, sc_w, sc_h); glEnable(GL_SCISSOR_TEST); diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index 5f01fc435..ddbb7e1c1 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -397,7 +397,7 @@ public: void DisableScissor() { - renderState.sc_x = -1; + renderState.sc_x = SHRT_MIN; renderState.StateFlags |= STF_SCISSORSET; } diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index 34be26719..a16f62a8f 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -142,20 +142,18 @@ void GLInstance::Draw2D(F2DDrawer *drawer) //state.EnableBrightmap(!(cmd.mRenderStyle.Flags & STYLEF_ColorIsFixed)); //state.SetTextureMode(cmd.mDrawMode); - int sciX, sciY, sciW, sciH; if (cmd.mFlags & F2DDrawer::DTF_Scissor) { // scissor test doesn't use the current viewport for the coordinates, so use real screen coordinates // Note that the origin here is the lower left corner! - sciX = screen->ScreenToWindowX(cmd.mScissor[0]); - sciY = screen->ScreenToWindowY(cmd.mScissor[3]); - sciW = screen->ScreenToWindowX(cmd.mScissor[2]) - sciX; - sciH = screen->ScreenToWindowY(cmd.mScissor[1]) - sciY; + int sciX = screen->ScreenToWindowX(cmd.mScissor[0]); + int sciY = screen->ScreenToWindowY(cmd.mScissor[3]); + int sciW = screen->ScreenToWindowX(cmd.mScissor[2]) - sciX; + int sciH = screen->ScreenToWindowY(cmd.mScissor[1]) - sciY; SetScissor(sciX, sciY, sciW, sciH); } else { - sciX = sciY = sciW = sciH = -1; DisableScissor(); }