mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 23:02:08 +00:00
- Fixed clipping in D3DFB::DrawTextureV() for good by using a scissor test.
SVN r1386 (trunk)
This commit is contained in:
parent
c09d9f0e20
commit
b680840073
2 changed files with 41 additions and 14 deletions
|
@ -1,3 +1,6 @@
|
|||
January 31, 2009
|
||||
- Fixed clipping in D3DFB::DrawTextureV() for good by using a scissor test.
|
||||
|
||||
January 30, 2009
|
||||
- Fixed: D3DFB::DrawTextureV() did not properly adjust the texture coordinate
|
||||
for lclip and rclip.
|
||||
|
|
|
@ -2405,18 +2405,7 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
|||
float u1 = tex->Box->Right;
|
||||
float v1 = tex->Box->Bottom;
|
||||
float uscale = 1.f / tex->Box->Owner->Width;
|
||||
float vscale = 1.f / tex->Box->Owner->Height / yscale;
|
||||
|
||||
if (y0 < parms.uclip)
|
||||
{
|
||||
v0 += (float(parms.uclip) - y0) * vscale;
|
||||
y0 = float(parms.uclip);
|
||||
}
|
||||
if (y1 > parms.dclip)
|
||||
{
|
||||
v1 -= (y1 - float(parms.dclip)) * vscale;
|
||||
y1 = float(parms.dclip);
|
||||
}
|
||||
bool scissoring = false;
|
||||
|
||||
if (parms.flipX)
|
||||
{
|
||||
|
@ -2429,16 +2418,45 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
|||
x1 -= (parms.texwidth - parms.windowright) * xscale;
|
||||
u1 -= (parms.texwidth - parms.windowright) * uscale;
|
||||
}
|
||||
#if 0
|
||||
float vscale = 1.f / tex->Box->Owner->Height / yscale;
|
||||
if (y0 < parms.uclip)
|
||||
{
|
||||
v0 += (float(parms.uclip) - y0) * vscale;
|
||||
y0 = float(parms.uclip);
|
||||
}
|
||||
if (y1 > parms.dclip)
|
||||
{
|
||||
v1 -= (y1 - float(parms.dclip)) * vscale;
|
||||
y1 = float(parms.dclip);
|
||||
}
|
||||
if (x0 < parms.lclip)
|
||||
{
|
||||
u0 += float(parms.lclip - x0) * uscale;
|
||||
u0 += float(parms.lclip - x0) * uscale / xscale * 2;
|
||||
x0 = float(parms.lclip);
|
||||
}
|
||||
if (x1 > parms.rclip)
|
||||
{
|
||||
u1 -= float(x1 - parms.rclip) * uscale;
|
||||
u1 -= (x1 - parms.rclip) * uscale / xscale * 2;
|
||||
x1 = float(parms.rclip);
|
||||
}
|
||||
#else
|
||||
// Use a scissor test because the math above introduces some jitter
|
||||
// that is noticeable at low resolutions. Unfortunately, this means this
|
||||
// quad has to be in a batch by itself.
|
||||
if (y0 < parms.uclip || y1 > parms.dclip || x0 < parms.lclip || x1 > parms.rclip)
|
||||
{
|
||||
scissoring = true;
|
||||
if (QuadBatchPos > 0)
|
||||
{
|
||||
EndQuadBatch();
|
||||
BeginQuadBatch();
|
||||
}
|
||||
RECT scissor = { parms.lclip, parms.uclip, parms.rclip, parms.dclip };
|
||||
D3DDevice->SetScissorRect(&scissor);
|
||||
D3DDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
|
||||
}
|
||||
#endif
|
||||
parms.bilinear = false;
|
||||
|
||||
D3DCOLOR color0, color1;
|
||||
|
@ -2511,6 +2529,12 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
|||
QuadBatchPos++;
|
||||
VertexPos += 4;
|
||||
IndexPos += 6;
|
||||
|
||||
if (scissoring)
|
||||
{
|
||||
EndQuadBatch();
|
||||
D3DDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
Loading…
Reference in a new issue