- fixed scissoring with out of range coordinates.

Blood's status bar sets such a bogus clipping rectangle.
This commit is contained in:
Christoph Oelckers 2020-01-05 10:21:34 +01:00
parent e84acb7e2f
commit 6c6874cb0e
4 changed files with 7 additions and 9 deletions

View File

@ -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;

View File

@ -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);

View File

@ -397,7 +397,7 @@ public:
void DisableScissor()
{
renderState.sc_x = -1;
renderState.sc_x = SHRT_MIN;
renderState.StateFlags |= STF_SCISSORSET;
}

View File

@ -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();
}