diff --git a/source/common/2d/v_2ddrawer.cpp b/source/common/2d/v_2ddrawer.cpp index 4f70e89f2..49ddac728 100644 --- a/source/common/2d/v_2ddrawer.cpp +++ b/source/common/2d/v_2ddrawer.cpp @@ -701,10 +701,14 @@ void F2DDrawer::rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 int method = 0; dg.mType = DrawTypeRotateSprite; - dg.mScissor[0] = cx1; - dg.mScissor[1] = cy1; - dg.mScissor[2] = cx2; - dg.mScissor[3] = cy2; + if (cx1 > 0 || cy1 > 0 || cx2 < xdim - 1 || cy2 < ydim - 1) + { + dg.mScissor[0] = cx1; + dg.mScissor[1] = cy1; + dg.mScissor[2] = cx2 + 1; + dg.mScissor[3] = cy2 + 1; + dg.mFlags |= DTF_Scissor; + } if (!(dastat & RS_NOMASK)) { @@ -730,8 +734,8 @@ void F2DDrawer::rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16 if (!(dastat & RS_TOPLEFT)) { - ofs = { int16_t(picanm[globalpicnum].xofs + (siz.x >> 1)), - int16_t(picanm[globalpicnum].yofs + (siz.y >> 1)) }; + ofs = { int16_t(picanm[picnum].xofs + (siz.x >> 1)), + int16_t(picanm[picnum].yofs + (siz.y >> 1)) }; } if (dastat & RS_YFLIP) diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 7e192ae15..2f54a8072 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -412,8 +412,15 @@ void GLInstance::SetCull(int type, int winding) void GLInstance::SetScissor(int x1, int y1, int x2, int y2) { glScissor(x1, y1, x2, y2); + glEnable(GL_SCISSOR_TEST); } +void GLInstance::DisableScissor() +{ + glDisable(GL_SCISSOR_TEST); +} + + void GLInstance::SetColor(float r, float g, float b, float a) { glVertexAttrib4f(2, r, g, b, a); diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index fcba66c22..f4c62fa7f 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -286,6 +286,7 @@ public: } void SetScissor(int x1, int y1, int x2, int y2); + void DisableScissor(); void SetDepthFunc(int func); void SetColorMask(bool on); void SetDepthMask(bool on); diff --git a/source/glbackend/hw_draw2d.cpp b/source/glbackend/hw_draw2d.cpp index 1abead275..cde0322ce 100644 --- a/source/glbackend/hw_draw2d.cpp +++ b/source/glbackend/hw_draw2d.cpp @@ -131,7 +131,6 @@ void GLInstance::Draw2D(F2DDrawer *drawer) int gltrans = -1; SetBlendFunc(cmd.mRenderStyle.SrcAlpha, cmd.mRenderStyle.DestAlpha); - EnableBlend(!(cmd.mRenderStyle.Flags & STYLEF_Alpha1)); //state.SetRenderStyle(cmd.mRenderStyle); //state.EnableBrightmap(!(cmd.mRenderStyle.Flags & STYLEF_ColorIsFixed)); //state.SetTextureMode(cmd.mDrawMode); @@ -145,12 +144,13 @@ void GLInstance::Draw2D(F2DDrawer *drawer) sciY = screen->ScreenToWindowY(cmd.mScissor[3]); sciW = screen->ScreenToWindowX(cmd.mScissor[2]) - sciX; sciH = screen->ScreenToWindowY(cmd.mScissor[1]) - sciY; + SetScissor(sciX, sciY, sciW, sciH); } else { sciX = sciY = sciW = sciH = -1; + DisableScissor(); } - SetScissor(sciX, sciY, sciW, sciH); //state.SetFog(cmd.mColor1, 0); SetColor(1, 1, 1); @@ -165,12 +165,14 @@ void GLInstance::Draw2D(F2DDrawer *drawer) SetShade(cmd.mRemapIndex >> 16, numshades); SetFadeDisable(false); SetTexture(0, tex, cmd.mRemapIndex & 0xffff, 4/*DAMETH_CLAMPED*/, SamplerClampXY); + EnableBlend(!(cmd.mRenderStyle.Flags & STYLEF_Alpha1)); } else { SetFadeDisable(true); SetShade(0, numshades); SetNamedTexture(cmd.mTexture, cmd.mRemapIndex, cmd.mFlags & F2DDrawer::DTF_Wrap ? SamplerRepeat : SamplerClampXY); + EnableBlend(true); } UseColorOnly(false); } @@ -214,6 +216,7 @@ void GLInstance::Draw2D(F2DDrawer *drawer) SetShade(0, numshades); SetFadeDisable(false); SetColor(1, 1, 1); + DisableScissor(); //drawer->mIsFirstPass = false; twod.Clear(); EnableBlend(true);