mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-21 11:21:04 +00:00
- Changed all coordinates for DrawTexture() to floating point so that the
player sprites will retain the same precision they had when they were rendered as part of the 3D view. (needed for propery alignment of flashes on top of weapon sprites) It worked just fine for D3D, but software rendering was another matter. I consequently did battle with imprecisions in the whole masked texture drawing routines that had previously been partially masked by only drawing on whole pixel boundaries. Particularly, the tops of posts are calculated by multiplying by spryscale, and the texture mapping coordinates are calculated by multiplying by dc_iscale (where dc_iscale = 1 / spryscale). Since these are both 16.16 fixed point values, there is a significant variance. For best results, the drawing routines should only use one of these values, but that would mean introducing division into the inner loop. If the division removed the necessity for the fudge code in R_DrawMaskedColumn(), would it be worth it? Or would the divide be slower than the fudging? Or would I be better off doing it like Build and using transparent pixel checks instead, not bothering with skipping transparent areas? For now, I chop off the fractional part of the top coordinate for software drawing, since it was the easiest thing to do (even if it wasn't the most correct thing to do). SVN r1955 (trunk)
This commit is contained in:
parent
a4f4994e18
commit
4ebfdac887
10 changed files with 657 additions and 551 deletions
|
@ -1,3 +1,24 @@
|
||||||
|
October 31, 2009
|
||||||
|
- Changed all coordinates for DrawTexture() to floating point so that the
|
||||||
|
player sprites will retain the same precision they had when they were
|
||||||
|
rendered as part of the 3D view. (needed for propery alignment of flashes
|
||||||
|
on top of weapon sprites) It worked just fine for D3D, but software
|
||||||
|
rendering was another matter. I consequently did battle with imprecisions
|
||||||
|
in the whole masked texture drawing routines that had previously been
|
||||||
|
partially masked by only drawing on whole pixel boundaries. Particularly,
|
||||||
|
the tops of posts are calculated by multiplying by spryscale, and the
|
||||||
|
texture mapping coordinates are calculated by multiplying by dc_iscale
|
||||||
|
(where dc_iscale = 1 / spryscale). Since these are both 16.16 fixed point
|
||||||
|
values, there is a significant variance. For best results, the drawing
|
||||||
|
routines should only use one of these values, but that would mean
|
||||||
|
introducing division into the inner loop. If the division removed the
|
||||||
|
necessity for the fudge code in R_DrawMaskedColumn(), would it be worth it?
|
||||||
|
Or would the divide be slower than the fudging? Or would I be better off
|
||||||
|
doing it like Build and using transparent pixel checks instead, not
|
||||||
|
bothering with skipping transparent areas? For now, I chop off the
|
||||||
|
fractional part of the top coordinate for software drawing, since it was
|
||||||
|
the easiest thing to do (even if it wasn't the most correct thing to do).
|
||||||
|
|
||||||
October 29, 2009
|
October 29, 2009
|
||||||
- Fixed: Sprites and decals that are drawn with addition must fade to black.
|
- Fixed: Sprites and decals that are drawn with addition must fade to black.
|
||||||
- Make TranslateToStartSpot() set the new sector references for a polyobj's
|
- Make TranslateToStartSpot() set the new sector references for a polyobj's
|
||||||
|
|
|
@ -960,7 +960,7 @@ void DSBarInfo::doCommands(SBarInfoBlock &block, int xOffset, int yOffset, int a
|
||||||
h = fg->GetScaledHeight() << FRACBITS;
|
h = fg->GetScaledHeight() << FRACBITS;
|
||||||
if (Scaled)
|
if (Scaled)
|
||||||
{
|
{
|
||||||
screen->VirtualToRealCoords(x, y, w, h, 320, 200, true);
|
screen->VirtualToRealCoordsFixed(x, y, w, h, 320, 200, true);
|
||||||
}
|
}
|
||||||
x >>= FRACBITS;
|
x >>= FRACBITS;
|
||||||
y >>= FRACBITS;
|
y >>= FRACBITS;
|
||||||
|
@ -1018,7 +1018,7 @@ void DSBarInfo::doCommands(SBarInfoBlock &block, int xOffset, int yOffset, int a
|
||||||
ch = (fg->GetScaledHeight() - fg->GetScaledTopOffset() - cmd.special3 * 2) << FRACBITS;
|
ch = (fg->GetScaledHeight() - fg->GetScaledTopOffset() - cmd.special3 * 2) << FRACBITS;
|
||||||
if (Scaled)
|
if (Scaled)
|
||||||
{
|
{
|
||||||
screen->VirtualToRealCoords(cx, cy, cw, ch, 320, 200, true);
|
screen->VirtualToRealCoordsFixed(cx, cy, cw, ch, 320, 200, true);
|
||||||
}
|
}
|
||||||
cx >>= FRACBITS;
|
cx >>= FRACBITS;
|
||||||
cy >>= FRACBITS;
|
cy >>= FRACBITS;
|
||||||
|
@ -1480,7 +1480,7 @@ void DSBarInfo::DrawGraphic(FTexture* texture, SBarInfoCoordinate x, SBarInfoCoo
|
||||||
fixed_t fw = texture->GetScaledWidth() << FRACBITS;
|
fixed_t fw = texture->GetScaledWidth() << FRACBITS;
|
||||||
fixed_t fh = texture->GetScaledHeight() << FRACBITS;
|
fixed_t fh = texture->GetScaledHeight() << FRACBITS;
|
||||||
if(Scaled)
|
if(Scaled)
|
||||||
screen->VirtualToRealCoords(fx, fy, fw, fh, 320, 200, true);
|
screen->VirtualToRealCoordsFixed(fx, fy, fw, fh, 320, 200, true);
|
||||||
// Round to nearest
|
// Round to nearest
|
||||||
w = (fw + (FRACUNIT>>1)) >> FRACBITS;
|
w = (fw + (FRACUNIT>>1)) >> FRACBITS;
|
||||||
h = (fh + (FRACUNIT>>1)) >> FRACBITS;
|
h = (fh + (FRACUNIT>>1)) >> FRACBITS;
|
||||||
|
|
|
@ -1848,9 +1848,9 @@ void R_DrawRemainingPlayerSprites()
|
||||||
}
|
}
|
||||||
screen->DrawTexture(vis->pic,
|
screen->DrawTexture(vis->pic,
|
||||||
viewwindowx + VisPSpritesX1[i],
|
viewwindowx + VisPSpritesX1[i],
|
||||||
viewwindowy + viewheight/2 - MulScale32(vis->texturemid, vis->yscale) - 1,
|
viewwindowy + viewheight/2 - (vis->texturemid / 65536.0) * (vis->yscale / 65536.0) - 1,
|
||||||
DTA_DestWidth, FixedMul(vis->pic->GetWidth(), vis->xscale),
|
DTA_DestWidthF, FIXED2FLOAT(vis->pic->GetWidth() * vis->xscale),
|
||||||
DTA_DestHeight, FixedMul(vis->pic->GetHeight(), vis->yscale),
|
DTA_DestHeightF, FIXED2FLOAT(vis->pic->GetHeight() * vis->yscale),
|
||||||
DTA_Translation, TranslationToTable(vis->Translation),
|
DTA_Translation, TranslationToTable(vis->Translation),
|
||||||
DTA_FlipX, flip,
|
DTA_FlipX, flip,
|
||||||
DTA_TopOffset, 0,
|
DTA_TopOffset, 0,
|
||||||
|
|
|
@ -178,9 +178,13 @@ public:
|
||||||
|
|
||||||
int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); }
|
int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); }
|
||||||
int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); }
|
int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); }
|
||||||
|
double GetScaledWidthDouble () { return (Width * 65536.f) / xScale; }
|
||||||
|
double GetScaledHeightDouble () { return (Height * 65536.f) / yScale; }
|
||||||
|
|
||||||
int GetScaledLeftOffset () { int foo = (LeftOffset << 17) / xScale; return (foo >> 1) + (foo & 1); }
|
int GetScaledLeftOffset () { int foo = (LeftOffset << 17) / xScale; return (foo >> 1) + (foo & 1); }
|
||||||
int GetScaledTopOffset () { int foo = (TopOffset << 17) / yScale; return (foo >> 1) + (foo & 1); }
|
int GetScaledTopOffset () { int foo = (TopOffset << 17) / yScale; return (foo >> 1) + (foo & 1); }
|
||||||
|
double GetScaledLeftOffsetDouble() { return (LeftOffset * 65536.f) / xScale; }
|
||||||
|
double GetScaledTopOffsetDouble() { return (TopOffset * 65536.f) / yScale; }
|
||||||
|
|
||||||
virtual void SetFrontSkyLayer();
|
virtual void SetFrontSkyLayer();
|
||||||
|
|
||||||
|
|
235
src/v_draw.cpp
235
src/v_draw.cpp
|
@ -89,14 +89,14 @@ static int PalFromRGB(uint32 rgb)
|
||||||
return LastPal;
|
return LastPal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STACK_ARGS DCanvas::DrawTexture (FTexture *img, int x, int y, int tags_first, ...)
|
void STACK_ARGS DCanvas::DrawTexture (FTexture *img, double x, double y, int tags_first, ...)
|
||||||
{
|
{
|
||||||
va_list tags;
|
va_list tags;
|
||||||
va_start(tags, tags_first);
|
va_start(tags, tags_first);
|
||||||
DrawTextureV(img, x, y, tags_first, tags);
|
DrawTextureV(img, x, y, tags_first, tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, int x, int y, uint32 tag, va_list tags)
|
void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, double x, double y, uint32 tag, va_list tags)
|
||||||
{
|
{
|
||||||
FTexture::Span unmaskedSpan[2];
|
FTexture::Span unmaskedSpan[2];
|
||||||
const FTexture::Span **spanptr, *spans;
|
const FTexture::Span **spanptr, *spans;
|
||||||
|
@ -154,8 +154,8 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, int x, int y, uint32 tag, v
|
||||||
BYTE *destorgsave = dc_destorg;
|
BYTE *destorgsave = dc_destorg;
|
||||||
dc_destorg = screen->GetBuffer();
|
dc_destorg = screen->GetBuffer();
|
||||||
|
|
||||||
fixed_t x0 = parms.x - Scale (parms.left, parms.destwidth, parms.texwidth);
|
double x0 = parms.x - parms.left * parms.destwidth / parms.texwidth;
|
||||||
fixed_t y0 = parms.y - Scale (parms.top, parms.destheight, parms.texheight);
|
double y0 = parms.y - parms.top * parms.destheight / parms.texheight;
|
||||||
|
|
||||||
if (mode != DontDraw)
|
if (mode != DontDraw)
|
||||||
{
|
{
|
||||||
|
@ -174,21 +174,33 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, int x, int y, uint32 tag, v
|
||||||
fixed_t centeryback = centeryfrac;
|
fixed_t centeryback = centeryfrac;
|
||||||
centeryfrac = 0;
|
centeryfrac = 0;
|
||||||
|
|
||||||
sprtopscreen = y0;
|
sprtopscreen = FLOAT2FIXED(y0);
|
||||||
spryscale = parms.destheight / img->GetHeight();
|
// There is not enough precision in the drawing routines to keep the full
|
||||||
|
// precision for y0. :(
|
||||||
|
sprtopscreen &= ~(FRACUNIT - 1);
|
||||||
|
|
||||||
|
double yscale = parms.destheight / img->GetHeight();
|
||||||
|
double iyscale = 1 / yscale;
|
||||||
|
|
||||||
|
spryscale = FLOAT2FIXED(yscale);
|
||||||
|
|
||||||
|
#if 0
|
||||||
// Fix precision errors that are noticeable at some resolutions
|
// Fix precision errors that are noticeable at some resolutions
|
||||||
if (((y0 + parms.destheight) >> FRACBITS) > ((y0 + spryscale * img->GetHeight()) >> FRACBITS))
|
if ((y0 + parms.destheight) > (y0 + yscale * img->GetHeight()))
|
||||||
{
|
{
|
||||||
spryscale++;
|
spryscale++;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
sprflipvert = false;
|
sprflipvert = false;
|
||||||
dc_iscale = 0xffffffffu / (unsigned)spryscale;
|
//dc_iscale = FLOAT2FIXED(iyscale);
|
||||||
dc_texturemid = FixedMul (-y0, dc_iscale);
|
//dc_texturemid = FLOAT2FIXED((-y0) * iyscale);
|
||||||
|
//dc_iscale = 0xffffffffu / (unsigned)spryscale;
|
||||||
|
dc_iscale = DivScale32(1, spryscale);
|
||||||
|
dc_texturemid = FixedMul(-sprtopscreen, dc_iscale) + FixedMul(centeryfrac-FRACUNIT, dc_iscale);
|
||||||
fixed_t frac = 0;
|
fixed_t frac = 0;
|
||||||
fixed_t xiscale = DivScale32 (img->GetWidth(), parms.destwidth);
|
double xiscale = parms.texwidth / parms.destwidth;
|
||||||
int x2 = (x0 + parms.destwidth) >> FRACBITS;
|
double x2 = x0 + parms.destwidth;
|
||||||
|
|
||||||
if (bottomclipper[0] != parms.dclip)
|
if (bottomclipper[0] != parms.dclip)
|
||||||
{
|
{
|
||||||
|
@ -214,48 +226,53 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, int x, int y, uint32 tag, v
|
||||||
xiscale = -xiscale;
|
xiscale = -xiscale;
|
||||||
}
|
}
|
||||||
|
|
||||||
dc_x = x0 >> FRACBITS;
|
|
||||||
if (parms.windowleft > 0 || parms.windowright < parms.texwidth)
|
if (parms.windowleft > 0 || parms.windowright < parms.texwidth)
|
||||||
{
|
{
|
||||||
fixed_t xscale = parms.destwidth / parms.texwidth;
|
double xscale = parms.destwidth / parms.texwidth;
|
||||||
dc_x += (parms.windowleft * xscale) >> FRACBITS;
|
x0 += parms.windowleft * xscale;
|
||||||
frac += parms.windowleft << FRACBITS;
|
frac += FLOAT2FIXED(parms.windowleft);
|
||||||
x2 -= ((parms.texwidth - parms.windowright) * xscale) >> FRACBITS;
|
x2 -= (parms.texwidth - parms.windowright) * xscale;
|
||||||
}
|
}
|
||||||
if (dc_x < parms.lclip)
|
if (x0 < parms.lclip)
|
||||||
{
|
{
|
||||||
frac += (parms.lclip - dc_x) * xiscale;
|
frac += FLOAT2FIXED((parms.lclip - x0) * xiscale);
|
||||||
dc_x = parms.lclip;
|
x0 = parms.lclip;
|
||||||
}
|
}
|
||||||
if (x2 > parms.rclip)
|
if (x2 > parms.rclip)
|
||||||
{
|
{
|
||||||
x2 = parms.rclip;
|
x2 = parms.rclip;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parms.destheight < 32*FRACUNIT)
|
// Drawing short output ought to fit in the data cache well enough
|
||||||
|
// if we draw one column at a time, so do that, since it's simpler.
|
||||||
|
if (parms.destheight < 32 || (parms.dclip - parms.uclip) < 32)
|
||||||
{
|
{
|
||||||
mode = DoDraw0;
|
mode = DoDraw0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dc_x = int(x0);
|
||||||
|
int x2_i = int(x2);
|
||||||
|
fixed_t xiscale_i = FLOAT2FIXED(xiscale);
|
||||||
|
|
||||||
if (mode == DoDraw0)
|
if (mode == DoDraw0)
|
||||||
{
|
{
|
||||||
// One column at a time
|
// One column at a time
|
||||||
stop4 = dc_x;
|
stop4 = dc_x;
|
||||||
}
|
}
|
||||||
else // DoDraw1
|
else // DoDraw1`
|
||||||
{
|
{
|
||||||
// Up to four columns at a time
|
// Up to four columns at a time
|
||||||
stop4 = x2 & ~3;
|
stop4 = x2_i & ~3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dc_x < x2)
|
if (dc_x < x2_i)
|
||||||
{
|
{
|
||||||
while ((dc_x < stop4) && (dc_x & 3))
|
while ((dc_x < stop4) && (dc_x & 3))
|
||||||
{
|
{
|
||||||
pixels = img->GetColumn(frac >> FRACBITS, spanptr);
|
pixels = img->GetColumn(frac >> FRACBITS, spanptr);
|
||||||
R_DrawMaskedColumn(pixels, spans);
|
R_DrawMaskedColumn(pixels, spans);
|
||||||
dc_x++;
|
dc_x++;
|
||||||
frac += xiscale;
|
frac += xiscale_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (dc_x < stop4)
|
while (dc_x < stop4)
|
||||||
|
@ -266,17 +283,17 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, int x, int y, uint32 tag, v
|
||||||
pixels = img->GetColumn(frac >> FRACBITS, spanptr);
|
pixels = img->GetColumn(frac >> FRACBITS, spanptr);
|
||||||
R_DrawMaskedColumnHoriz(pixels, spans);
|
R_DrawMaskedColumnHoriz(pixels, spans);
|
||||||
dc_x++;
|
dc_x++;
|
||||||
frac += xiscale;
|
frac += xiscale_i;
|
||||||
}
|
}
|
||||||
rt_draw4cols(dc_x - 4);
|
rt_draw4cols(dc_x - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (dc_x < x2)
|
while (dc_x < x2_i)
|
||||||
{
|
{
|
||||||
pixels = img->GetColumn(frac >> FRACBITS, spanptr);
|
pixels = img->GetColumn(frac >> FRACBITS, spanptr);
|
||||||
R_DrawMaskedColumn(pixels, spans);
|
R_DrawMaskedColumn(pixels, spans);
|
||||||
dc_x++;
|
dc_x++;
|
||||||
frac += xiscale;
|
frac += xiscale_i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
centeryfrac = centeryback;
|
centeryfrac = centeryback;
|
||||||
|
@ -291,7 +308,7 @@ void STACK_ARGS DCanvas::DrawTextureV(FTexture *img, int x, int y, uint32 tag, v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_list tags, DrawParms *parms, bool hw) const
|
bool DCanvas::ParseDrawTextureTags (FTexture *img, double x, double y, DWORD tag, va_list tags, DrawParms *parms, bool hw) const
|
||||||
{
|
{
|
||||||
INTBOOL boolval;
|
INTBOOL boolval;
|
||||||
int intval;
|
int intval;
|
||||||
|
@ -313,8 +330,8 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
|
|
||||||
virtBottom = false;
|
virtBottom = false;
|
||||||
|
|
||||||
parms->texwidth = img->GetScaledWidth();
|
parms->texwidth = img->GetScaledWidthDouble();
|
||||||
parms->texheight = img->GetScaledHeight();
|
parms->texheight = img->GetScaledHeightDouble();
|
||||||
|
|
||||||
parms->windowleft = 0;
|
parms->windowleft = 0;
|
||||||
parms->windowright = parms->texwidth;
|
parms->windowright = parms->texwidth;
|
||||||
|
@ -322,8 +339,8 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
parms->uclip = 0;
|
parms->uclip = 0;
|
||||||
parms->lclip = 0;
|
parms->lclip = 0;
|
||||||
parms->rclip = this->GetWidth();
|
parms->rclip = this->GetWidth();
|
||||||
parms->destwidth = parms->windowright << FRACBITS;
|
parms->destwidth = parms->windowright;
|
||||||
parms->destheight = parms->texheight << FRACBITS;
|
parms->destheight = parms->texheight;
|
||||||
parms->top = img->GetScaledTopOffset();
|
parms->top = img->GetScaledTopOffset();
|
||||||
parms->left = img->GetScaledLeftOffset();
|
parms->left = img->GetScaledLeftOffset();
|
||||||
parms->alpha = FRACUNIT;
|
parms->alpha = FRACUNIT;
|
||||||
|
@ -344,10 +361,12 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
parms->specialcolormap = NULL;
|
parms->specialcolormap = NULL;
|
||||||
parms->colormapstyle = NULL;
|
parms->colormapstyle = NULL;
|
||||||
|
|
||||||
parms->x = x << FRACBITS;
|
parms->x = x;
|
||||||
parms->y = y << FRACBITS;
|
parms->y = y;
|
||||||
|
|
||||||
// Parse the tag list for attributes
|
// Parse the tag list for attributes. (For floating point attributes,
|
||||||
|
// consider that the C ABI dictates that all floats be promoted to
|
||||||
|
// doubles when passed as function arguments.)
|
||||||
while (tag != TAG_DONE)
|
while (tag != TAG_DONE)
|
||||||
{
|
{
|
||||||
va_list *more_p;
|
va_list *more_p;
|
||||||
|
@ -371,21 +390,29 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_DestWidth:
|
case DTA_DestWidth:
|
||||||
parms->destwidth = va_arg (tags, int) << FRACBITS;
|
parms->destwidth = va_arg(tags, int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DTA_DestWidthF:
|
||||||
|
parms->destwidth = va_arg(tags, double);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_DestHeight:
|
case DTA_DestHeight:
|
||||||
parms->destheight = va_arg (tags, int) << FRACBITS;
|
parms->destheight = va_arg(tags, int);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DTA_DestHeightF:
|
||||||
|
parms->destheight = va_arg(tags, double);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_Clean:
|
case DTA_Clean:
|
||||||
boolval = va_arg(tags, INTBOOL);
|
boolval = va_arg(tags, INTBOOL);
|
||||||
if (boolval)
|
if (boolval)
|
||||||
{
|
{
|
||||||
parms->x = (parms->x - 160*FRACUNIT) * CleanXfac + (Width * (FRACUNIT/2));
|
parms->x = (parms->x - 160.0) * CleanXfac + (Width * 0.5);
|
||||||
parms->y = (parms->y - 100*FRACUNIT) * CleanYfac + (Height * (FRACUNIT/2));
|
parms->y = (parms->y - 100.0) * CleanYfac + (Height * 0.5);
|
||||||
parms->destwidth = parms->texwidth * CleanXfac * FRACUNIT;
|
parms->destwidth = parms->texwidth * CleanXfac;
|
||||||
parms->destheight = parms->texheight * CleanYfac * FRACUNIT;
|
parms->destheight = parms->texheight * CleanYfac;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -393,8 +420,8 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
boolval = va_arg(tags, INTBOOL);
|
boolval = va_arg(tags, INTBOOL);
|
||||||
if (boolval)
|
if (boolval)
|
||||||
{
|
{
|
||||||
parms->destwidth = parms->texwidth * CleanXfac * FRACUNIT;
|
parms->destwidth = parms->texwidth * CleanXfac;
|
||||||
parms->destheight = parms->texheight * CleanYfac * FRACUNIT;
|
parms->destheight = parms->texheight * CleanYfac;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -427,23 +454,23 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
{
|
{
|
||||||
parms->x *= CleanXfac;
|
parms->x *= CleanXfac;
|
||||||
if (intval == HUD_HorizCenter)
|
if (intval == HUD_HorizCenter)
|
||||||
parms->x += Width * FRACUNIT / 2;
|
parms->x += Width * 0.5;
|
||||||
else if (xright)
|
else if (xright)
|
||||||
parms->x = Width * FRACUNIT + parms->x;
|
parms->x = Width + parms->x;
|
||||||
parms->y *= CleanYfac;
|
parms->y *= CleanYfac;
|
||||||
if (ybot)
|
if (ybot)
|
||||||
parms->y = Height * FRACUNIT + parms->y;
|
parms->y = Height + parms->y;
|
||||||
parms->destwidth = parms->texwidth * CleanXfac * FRACUNIT;
|
parms->destwidth = parms->texwidth * CleanXfac;
|
||||||
parms->destheight = parms->texheight * CleanYfac * FRACUNIT;
|
parms->destheight = parms->texheight * CleanYfac;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (intval == HUD_HorizCenter)
|
if (intval == HUD_HorizCenter)
|
||||||
parms->x += Width * FRACUNIT / 2;
|
parms->x += Width * 0.5;
|
||||||
else if (xright)
|
else if (xright)
|
||||||
parms->x = Width * FRACUNIT + parms->x;
|
parms->x = Width + parms->x;
|
||||||
if (ybot)
|
if (ybot)
|
||||||
parms->y = Height * FRACUNIT + parms->y;
|
parms->y = Height + parms->y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -452,10 +479,18 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
parms->virtWidth = va_arg(tags, int);
|
parms->virtWidth = va_arg(tags, int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DTA_VirtualWidthF:
|
||||||
|
parms->virtWidth = va_arg(tags, double);
|
||||||
|
break;
|
||||||
|
|
||||||
case DTA_VirtualHeight:
|
case DTA_VirtualHeight:
|
||||||
parms->virtHeight = va_arg(tags, int);
|
parms->virtHeight = va_arg(tags, int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DTA_VirtualHeightF:
|
||||||
|
parms->virtHeight = va_arg(tags, double);
|
||||||
|
break;
|
||||||
|
|
||||||
case DTA_Alpha:
|
case DTA_Alpha:
|
||||||
parms->alpha = MIN<fixed_t>(FRACUNIT, va_arg (tags, fixed_t));
|
parms->alpha = MIN<fixed_t>(FRACUNIT, va_arg (tags, fixed_t));
|
||||||
break;
|
break;
|
||||||
|
@ -465,7 +500,7 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_FillColor:
|
case DTA_FillColor:
|
||||||
parms->fillcolor = va_arg (tags, int);
|
parms->fillcolor = va_arg(tags, uint32);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_Translation:
|
case DTA_Translation:
|
||||||
|
@ -484,22 +519,30 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
parms->top = va_arg(tags, int);
|
parms->top = va_arg(tags, int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DTA_TopOffsetF:
|
||||||
|
parms->top = va_arg(tags, double);
|
||||||
|
break;
|
||||||
|
|
||||||
case DTA_LeftOffset:
|
case DTA_LeftOffset:
|
||||||
parms->left = va_arg(tags, int);
|
parms->left = va_arg(tags, int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DTA_LeftOffsetF:
|
||||||
|
parms->left = va_arg(tags, double);
|
||||||
|
break;
|
||||||
|
|
||||||
case DTA_CenterOffset:
|
case DTA_CenterOffset:
|
||||||
if (va_arg(tags, int))
|
if (va_arg(tags, int))
|
||||||
{
|
{
|
||||||
parms->left = parms->texwidth / 2;
|
parms->left = parms->texwidth * 0.5;
|
||||||
parms->top = parms->texheight / 2;
|
parms->top = parms->texheight * 0.5;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_CenterBottomOffset:
|
case DTA_CenterBottomOffset:
|
||||||
if (va_arg(tags, int))
|
if (va_arg(tags, int))
|
||||||
{
|
{
|
||||||
parms->left = parms->texwidth / 2;
|
parms->left = parms->texwidth * 0.5;
|
||||||
parms->top = parms->texheight;
|
parms->top = parms->texheight;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -508,10 +551,18 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
parms->windowleft = va_arg(tags, int);
|
parms->windowleft = va_arg(tags, int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DTA_WindowLeftF:
|
||||||
|
parms->windowleft = va_arg(tags, double);
|
||||||
|
break;
|
||||||
|
|
||||||
case DTA_WindowRight:
|
case DTA_WindowRight:
|
||||||
parms->windowright = va_arg(tags, int);
|
parms->windowright = va_arg(tags, int);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case DTA_WindowRightF:
|
||||||
|
parms->windowright = va_arg(tags, double);
|
||||||
|
break;
|
||||||
|
|
||||||
case DTA_ClipTop:
|
case DTA_ClipTop:
|
||||||
parms->uclip = va_arg(tags, int);
|
parms->uclip = va_arg(tags, int);
|
||||||
if (parms->uclip < 0)
|
if (parms->uclip < 0)
|
||||||
|
@ -645,66 +696,72 @@ bool DCanvas::ParseDrawTextureTags (FTexture *img, int x, int y, DWORD tag, va_l
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCanvas::VirtualToRealCoords(fixed_t &x, fixed_t &y, fixed_t &w, fixed_t &h,
|
void DCanvas::VirtualToRealCoords(double &x, double &y, double &w, double &h,
|
||||||
int vwidth, int vheight, bool vbottom, bool handleaspect) const
|
double vwidth, double vheight, bool vbottom, bool handleaspect) const
|
||||||
{
|
{
|
||||||
int myratio = handleaspect ? CheckRatio (Width, Height) : 0;
|
int myratio = handleaspect ? CheckRatio (Width, Height) : 0;
|
||||||
int right = x + w;
|
double right = x + w;
|
||||||
int bottom = y + h;
|
double bottom = y + h;
|
||||||
|
|
||||||
if (myratio != 0 && myratio != 4)
|
if (myratio != 0 && myratio != 4)
|
||||||
{ // The target surface is either 16:9 or 16:10, so expand the
|
{ // The target surface is either 16:9 or 16:10, so expand the
|
||||||
// specified virtual size to avoid undesired stretching of the
|
// specified virtual size to avoid undesired stretching of the
|
||||||
// image. Does not handle non-4:3 virtual sizes. I'll worry about
|
// image. Does not handle non-4:3 virtual sizes. I'll worry about
|
||||||
// those if somebody expresses a desire to use them.
|
// those if somebody expresses a desire to use them.
|
||||||
x = Scale(x - vwidth*FRACUNIT/2,
|
x = (x - vwidth * 0.5) * Width * 960 / (vwidth * BaseRatioSizes[myratio][0]) + Width * 0.5;
|
||||||
Width*960,
|
w = (right - vwidth * 0.5) * Width * 960 / (vwidth * BaseRatioSizes[myratio][0]) + Width * 0.5 - x;
|
||||||
vwidth*BaseRatioSizes[myratio][0])
|
|
||||||
+ Width*FRACUNIT/2;
|
|
||||||
w = Scale(right - vwidth*FRACUNIT/2,
|
|
||||||
Width*960,
|
|
||||||
vwidth*BaseRatioSizes[myratio][0])
|
|
||||||
+ Width*FRACUNIT/2 - x;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
x = Scale (x, Width, vwidth);
|
x = x * Width / vwidth;
|
||||||
w = Scale (right, Width, vwidth) - x;
|
w = right * Width / vwidth - x;
|
||||||
}
|
}
|
||||||
if (myratio == 4)
|
if (myratio == 4)
|
||||||
{ // The target surface is 5:4
|
{ // The target surface is 5:4
|
||||||
y = Scale(y - vheight*FRACUNIT/2,
|
y = (y - vheight * 0.5) * Height * 600 / (vheight * BaseRatioSizes[myratio][1]) + Height * 0.5;
|
||||||
Height*600,
|
h = (bottom - vheight * 0.5) * Height * 600 / (vheight * BaseRatioSizes[myratio][1]) + Height * 0.5 - y;
|
||||||
vheight*BaseRatioSizes[myratio][1])
|
|
||||||
+ Height*FRACUNIT/2;
|
|
||||||
h = Scale(bottom - vheight*FRACUNIT/2,
|
|
||||||
Height*600,
|
|
||||||
vheight*BaseRatioSizes[myratio][1])
|
|
||||||
+ Height*FRACUNIT/2 - y;
|
|
||||||
if (vbottom)
|
if (vbottom)
|
||||||
{
|
{
|
||||||
y += (Height - Height * BaseRatioSizes[myratio][3] / 48) << (FRACBITS - 1);
|
y += (Height - Height * BaseRatioSizes[myratio][3] / 48.0) * 0.5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
y = Scale (y, Height, vheight);
|
y = y * Height / vheight;
|
||||||
h = Scale (bottom, Height, vheight) - y;
|
h = bottom * Height / vheight - y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DCanvas::VirtualToRealCoordsFixed(fixed_t &x, fixed_t &y, fixed_t &w, fixed_t &h,
|
||||||
|
int vwidth, int vheight, bool vbottom, bool handleaspect) const
|
||||||
|
{
|
||||||
|
double dx, dy, dw, dh;
|
||||||
|
|
||||||
|
dx = FIXED2FLOAT(x);
|
||||||
|
dy = FIXED2FLOAT(y);
|
||||||
|
dw = FIXED2FLOAT(w);
|
||||||
|
dh = FIXED2FLOAT(h);
|
||||||
|
VirtualToRealCoords(dx, dy, dw, dh, vwidth, vheight, vbottom, handleaspect);
|
||||||
|
x = FLOAT2FIXED(dx);
|
||||||
|
y = FLOAT2FIXED(dy);
|
||||||
|
w = FLOAT2FIXED(dw);
|
||||||
|
h = FLOAT2FIXED(dh);
|
||||||
|
}
|
||||||
|
|
||||||
void DCanvas::VirtualToRealCoordsInt(int &x, int &y, int &w, int &h,
|
void DCanvas::VirtualToRealCoordsInt(int &x, int &y, int &w, int &h,
|
||||||
int vwidth, int vheight, bool vbottom, bool handleaspect) const
|
int vwidth, int vheight, bool vbottom, bool handleaspect) const
|
||||||
{
|
{
|
||||||
x <<= FRACBITS;
|
double dx, dy, dw, dh;
|
||||||
y <<= FRACBITS;
|
|
||||||
w <<= FRACBITS;
|
dx = x;
|
||||||
h <<= FRACBITS;
|
dy = y;
|
||||||
VirtualToRealCoords(x, y, w, h, vwidth, vheight, vbottom, handleaspect);
|
dw = w;
|
||||||
x >>= FRACBITS;
|
dh = h;
|
||||||
y >>= FRACBITS;
|
VirtualToRealCoords(dx, dy, dw, dh, vwidth, vheight, vbottom, handleaspect);
|
||||||
w >>= FRACBITS;
|
x = int(dx + 0.5);
|
||||||
h >>= FRACBITS;
|
y = int(dy + 0.5);
|
||||||
|
w = int(dx + dw + 0.5) - x;
|
||||||
|
h = int(dy + dh + 0.5) - y;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCanvas::FillBorder (FTexture *img)
|
void DCanvas::FillBorder (FTexture *img)
|
||||||
|
|
|
@ -87,8 +87,8 @@ enum
|
||||||
DTA_VirtualHeight, // pretend the canvas is this tall
|
DTA_VirtualHeight, // pretend the canvas is this tall
|
||||||
DTA_TopOffset, // override texture's top offset
|
DTA_TopOffset, // override texture's top offset
|
||||||
DTA_LeftOffset, // override texture's left offset
|
DTA_LeftOffset, // override texture's left offset
|
||||||
DTA_CenterOffset, // override texture's left and top offsets and set them for the texture's middle
|
DTA_CenterOffset, // bool: override texture's left and top offsets and set them for the texture's middle
|
||||||
DTA_CenterBottomOffset,// override texture's left and top offsets and set them for the texture's bottom middle
|
DTA_CenterBottomOffset,// bool: override texture's left and top offsets and set them for the texture's bottom middle
|
||||||
DTA_WindowLeft, // don't draw anything left of this column (on source, not dest)
|
DTA_WindowLeft, // don't draw anything left of this column (on source, not dest)
|
||||||
DTA_WindowRight, // don't draw anything at or to the right of this column (on source, not dest)
|
DTA_WindowRight, // don't draw anything at or to the right of this column (on source, not dest)
|
||||||
DTA_ClipTop, // don't draw anything above this row (on dest, not source)
|
DTA_ClipTop, // don't draw anything above this row (on dest, not source)
|
||||||
|
@ -104,6 +104,16 @@ enum
|
||||||
DTA_SpecialColormap,// pointer to FSpecialColormapParameters (likely to be forever hardware-only)
|
DTA_SpecialColormap,// pointer to FSpecialColormapParameters (likely to be forever hardware-only)
|
||||||
DTA_ColormapStyle, // pointer to FColormapStyle (hardware-only)
|
DTA_ColormapStyle, // pointer to FColormapStyle (hardware-only)
|
||||||
|
|
||||||
|
// floating point duplicates of some of the above:
|
||||||
|
DTA_DestWidthF,
|
||||||
|
DTA_DestHeightF,
|
||||||
|
DTA_TopOffsetF,
|
||||||
|
DTA_LeftOffsetF,
|
||||||
|
DTA_VirtualWidthF,
|
||||||
|
DTA_VirtualHeightF,
|
||||||
|
DTA_WindowLeftF,
|
||||||
|
DTA_WindowRightF,
|
||||||
|
|
||||||
// For DrawText calls:
|
// For DrawText calls:
|
||||||
DTA_TextLen, // stop after this many characters, even if \0 not hit
|
DTA_TextLen, // stop after this many characters, even if \0 not hit
|
||||||
DTA_CellX, // horizontal size of character cell
|
DTA_CellX, // horizontal size of character cell
|
||||||
|
@ -188,9 +198,12 @@ public:
|
||||||
// Text drawing functions -----------------------------------------------
|
// Text drawing functions -----------------------------------------------
|
||||||
|
|
||||||
// 2D Texture drawing
|
// 2D Texture drawing
|
||||||
void STACK_ARGS DrawTexture (FTexture *img, int x, int y, int tags, ...);
|
void STACK_ARGS DrawTexture (FTexture *img, double x, double y, int tags, ...);
|
||||||
void FillBorder (FTexture *img); // Fills the border around a 4:3 part of the screen on non-4:3 displays
|
void FillBorder (FTexture *img); // Fills the border around a 4:3 part of the screen on non-4:3 displays
|
||||||
void VirtualToRealCoords(fixed_t &x, fixed_t &y, fixed_t &w, fixed_t &h, int vwidth, int vheight, bool vbottom=false, bool handleaspect=true) const;
|
void VirtualToRealCoords(double &x, double &y, double &w, double &h, double vwidth, double vheight, bool vbottom=false, bool handleaspect=true) const;
|
||||||
|
|
||||||
|
// Code that uses these (i.e. SBARINFO) should probably be evaluated for using doubles all around instead.
|
||||||
|
void VirtualToRealCoordsFixed(fixed_t &x, fixed_t &y, fixed_t &w, fixed_t &h, int vwidth, int vheight, bool vbottom=false, bool handleaspect=true) const;
|
||||||
void VirtualToRealCoordsInt(int &x, int &y, int &w, int &h, int vwidth, int vheight, bool vbottom=false, bool handleaspect=true) const;
|
void VirtualToRealCoordsInt(int &x, int &y, int &w, int &h, int vwidth, int vheight, bool vbottom=false, bool handleaspect=true) const;
|
||||||
|
|
||||||
// 2D Text drawing
|
// 2D Text drawing
|
||||||
|
@ -199,21 +212,23 @@ public:
|
||||||
|
|
||||||
struct DrawParms
|
struct DrawParms
|
||||||
{
|
{
|
||||||
fixed_t x, y;
|
double x, y;
|
||||||
int texwidth;
|
double texwidth;
|
||||||
int texheight;
|
double texheight;
|
||||||
int windowleft;
|
double destwidth;
|
||||||
int windowright;
|
double destheight;
|
||||||
|
double virtWidth;
|
||||||
|
double virtHeight;
|
||||||
|
double windowleft;
|
||||||
|
double windowright;
|
||||||
int dclip;
|
int dclip;
|
||||||
int uclip;
|
int uclip;
|
||||||
int lclip;
|
int lclip;
|
||||||
int rclip;
|
int rclip;
|
||||||
fixed_t destwidth;
|
double top;
|
||||||
fixed_t destheight;
|
double left;
|
||||||
int top;
|
|
||||||
int left;
|
|
||||||
fixed_t alpha;
|
fixed_t alpha;
|
||||||
int fillcolor;
|
uint32 fillcolor;
|
||||||
FRemapTable *remap;
|
FRemapTable *remap;
|
||||||
const BYTE *translation;
|
const BYTE *translation;
|
||||||
DWORD colorOverlay;
|
DWORD colorOverlay;
|
||||||
|
@ -221,8 +236,6 @@ public:
|
||||||
INTBOOL flipX;
|
INTBOOL flipX;
|
||||||
fixed_t shadowAlpha;
|
fixed_t shadowAlpha;
|
||||||
int shadowColor;
|
int shadowColor;
|
||||||
int virtWidth;
|
|
||||||
int virtHeight;
|
|
||||||
INTBOOL keepratio;
|
INTBOOL keepratio;
|
||||||
INTBOOL masked;
|
INTBOOL masked;
|
||||||
INTBOOL bilinear;
|
INTBOOL bilinear;
|
||||||
|
@ -239,8 +252,8 @@ protected:
|
||||||
int LockCount;
|
int LockCount;
|
||||||
|
|
||||||
bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const;
|
bool ClipBox (int &left, int &top, int &width, int &height, const BYTE *&src, const int srcpitch) const;
|
||||||
virtual void STACK_ARGS DrawTextureV (FTexture *img, int x, int y, uint32 tag, va_list tags);
|
virtual void STACK_ARGS DrawTextureV (FTexture *img, double x, double y, uint32 tag, va_list tags);
|
||||||
bool ParseDrawTextureTags (FTexture *img, int x, int y, uint32 tag, va_list tags, DrawParms *parms, bool hw) const;
|
bool ParseDrawTextureTags (FTexture *img, double x, double y, uint32 tag, va_list tags, DrawParms *parms, bool hw) const;
|
||||||
|
|
||||||
DCanvas() {}
|
DCanvas() {}
|
||||||
|
|
||||||
|
@ -339,7 +352,7 @@ public:
|
||||||
// Tells the device to recreate itself with the new setting from vid_refreshrate.
|
// Tells the device to recreate itself with the new setting from vid_refreshrate.
|
||||||
virtual void NewRefreshRate ();
|
virtual void NewRefreshRate ();
|
||||||
|
|
||||||
// Set the rect defining the area effected by blending.
|
// Set the rect defining the area affected by blending.
|
||||||
virtual void SetBlendingRect (int x1, int y1, int x2, int y2);
|
virtual void SetBlendingRect (int x1, int y1, int x2, int y2);
|
||||||
|
|
||||||
// render 3D view
|
// render 3D view
|
||||||
|
@ -470,6 +483,7 @@ extern "C" void ASM_PatchPitch (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int CheckRatio (int width, int height);
|
int CheckRatio (int width, int height);
|
||||||
|
static inline int CheckRatio (double width, double height) { return CheckRatio(int(width), int(height)); }
|
||||||
extern const int BaseRatioSizes[5][4];
|
extern const int BaseRatioSizes[5][4];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1231,6 +1231,6 @@ typedef TMatrix3x3<float> FMatrix3x3;
|
||||||
typedef TAngle<float> FAngle;
|
typedef TAngle<float> FAngle;
|
||||||
|
|
||||||
#define FLOAT2FIXED(f) fixed_t((f) * float(65536))
|
#define FLOAT2FIXED(f) fixed_t((f) * float(65536))
|
||||||
#define FIXED2FLOAT(f) (float(f) / float(65536))
|
#define FIXED2FLOAT(f) ((f) / float(65536))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2734,7 +2734,7 @@ void D3DFB::DrawPixel(int x, int y, int palcolor, uint32 color)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_first, va_list tags)
|
void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, double x, double y, uint32 tags_first, va_list tags)
|
||||||
{
|
{
|
||||||
if (In2D < 2)
|
if (In2D < 2)
|
||||||
{
|
{
|
||||||
|
@ -2759,17 +2759,17 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
||||||
|
|
||||||
CheckQuadBatch();
|
CheckQuadBatch();
|
||||||
|
|
||||||
float xscale = float(parms.destwidth) / parms.texwidth / 65536.f;
|
double xscale = parms.destwidth / parms.texwidth;
|
||||||
float yscale = float(parms.destheight) / parms.texheight / 65536.f;
|
double yscale = parms.destheight / parms.texheight;
|
||||||
float x0 = float(parms.x) / 65536.f - float(parms.left) * xscale;
|
double x0 = parms.x - parms.left * xscale;
|
||||||
float y0 = float(parms.y) / 65536.f - float(parms.top) * yscale;
|
double y0 = parms.y - parms.top * yscale;
|
||||||
float x1 = x0 + float(parms.destwidth) / 65536.f;
|
double x1 = x0 + parms.destwidth;
|
||||||
float y1 = y0 + float(parms.destheight) / 65536.f;
|
double y1 = y0 + parms.destheight;
|
||||||
float u0 = tex->Box->Left;
|
float u0 = tex->Box->Left;
|
||||||
float v0 = tex->Box->Top;
|
float v0 = tex->Box->Top;
|
||||||
float u1 = tex->Box->Right;
|
float u1 = tex->Box->Right;
|
||||||
float v1 = tex->Box->Bottom;
|
float v1 = tex->Box->Bottom;
|
||||||
float uscale = 1.f / tex->Box->Owner->Width;
|
double uscale = 1.f / tex->Box->Owner->Width;
|
||||||
bool scissoring = false;
|
bool scissoring = false;
|
||||||
|
|
||||||
if (parms.flipX)
|
if (parms.flipX)
|
||||||
|
@ -2779,9 +2779,9 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
||||||
if (parms.windowleft > 0 || parms.windowright < parms.texwidth)
|
if (parms.windowleft > 0 || parms.windowright < parms.texwidth)
|
||||||
{
|
{
|
||||||
x0 += parms.windowleft * xscale;
|
x0 += parms.windowleft * xscale;
|
||||||
u0 += parms.windowleft * uscale;
|
u0 = float(u0 + parms.windowleft * uscale);
|
||||||
x1 -= (parms.texwidth - parms.windowright) * xscale;
|
x1 -= (parms.texwidth - parms.windowright) * xscale;
|
||||||
u1 -= (parms.texwidth - parms.windowright) * uscale;
|
u1 = float(u1 - (parms.texwidth - parms.windowright) * uscale);
|
||||||
}
|
}
|
||||||
#if 0
|
#if 0
|
||||||
float vscale = 1.f / tex->Box->Owner->Height / yscale;
|
float vscale = 1.f / tex->Box->Owner->Height / yscale;
|
||||||
|
@ -2841,6 +2841,7 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
||||||
|
|
||||||
float yoffs = GatheringWipeScreen ? 0.5f : 0.5f - LBOffset;
|
float yoffs = GatheringWipeScreen ? 0.5f : 0.5f - LBOffset;
|
||||||
|
|
||||||
|
#if 0
|
||||||
// Coordinates are truncated to integers, because that's effectively
|
// Coordinates are truncated to integers, because that's effectively
|
||||||
// what the software renderer does. The hardware will instead round
|
// what the software renderer does. The hardware will instead round
|
||||||
// to nearest, it seems.
|
// to nearest, it seems.
|
||||||
|
@ -2848,11 +2849,18 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
||||||
y0 = floorf(y0) - yoffs;
|
y0 = floorf(y0) - yoffs;
|
||||||
x1 = floorf(x1) - 0.5f;
|
x1 = floorf(x1) - 0.5f;
|
||||||
y1 = floorf(y1) - yoffs;
|
y1 = floorf(y1) - yoffs;
|
||||||
|
#else
|
||||||
|
x0 = x0 - 0.5f;
|
||||||
|
y0 = y0 - yoffs;
|
||||||
|
x1 = x1 - 0.5f;
|
||||||
|
y1 = y1 - yoffs;
|
||||||
|
#endif
|
||||||
|
|
||||||
FBVERTEX *vert = &VertexData[VertexPos];
|
FBVERTEX *vert = &VertexData[VertexPos];
|
||||||
|
|
||||||
vert[0].x = x0;
|
// Fill the vertex buffer.
|
||||||
vert[0].y = y0;
|
vert[0].x = float(x0);
|
||||||
|
vert[0].y = float(y0);
|
||||||
vert[0].z = 0;
|
vert[0].z = 0;
|
||||||
vert[0].rhw = 1;
|
vert[0].rhw = 1;
|
||||||
vert[0].color0 = color0;
|
vert[0].color0 = color0;
|
||||||
|
@ -2860,8 +2868,8 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
||||||
vert[0].tu = u0;
|
vert[0].tu = u0;
|
||||||
vert[0].tv = v0;
|
vert[0].tv = v0;
|
||||||
|
|
||||||
vert[1].x = x1;
|
vert[1].x = float(x1);
|
||||||
vert[1].y = y0;
|
vert[1].y = float(y0);
|
||||||
vert[1].z = 0;
|
vert[1].z = 0;
|
||||||
vert[1].rhw = 1;
|
vert[1].rhw = 1;
|
||||||
vert[1].color0 = color0;
|
vert[1].color0 = color0;
|
||||||
|
@ -2869,8 +2877,8 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
||||||
vert[1].tu = u1;
|
vert[1].tu = u1;
|
||||||
vert[1].tv = v0;
|
vert[1].tv = v0;
|
||||||
|
|
||||||
vert[2].x = x1;
|
vert[2].x = float(x1);
|
||||||
vert[2].y = y1;
|
vert[2].y = float(y1);
|
||||||
vert[2].z = 0;
|
vert[2].z = 0;
|
||||||
vert[2].rhw = 1;
|
vert[2].rhw = 1;
|
||||||
vert[2].color0 = color0;
|
vert[2].color0 = color0;
|
||||||
|
@ -2878,8 +2886,8 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
||||||
vert[2].tu = u1;
|
vert[2].tu = u1;
|
||||||
vert[2].tv = v1;
|
vert[2].tv = v1;
|
||||||
|
|
||||||
vert[3].x = x0;
|
vert[3].x = float(x0);
|
||||||
vert[3].y = y1;
|
vert[3].y = float(y1);
|
||||||
vert[3].z = 0;
|
vert[3].z = 0;
|
||||||
vert[3].rhw = 1;
|
vert[3].rhw = 1;
|
||||||
vert[3].color0 = color0;
|
vert[3].color0 = color0;
|
||||||
|
@ -2887,6 +2895,7 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
||||||
vert[3].tu = u0;
|
vert[3].tu = u0;
|
||||||
vert[3].tv = v1;
|
vert[3].tv = v1;
|
||||||
|
|
||||||
|
// Fill the vertex index buffer.
|
||||||
IndexData[IndexPos ] = VertexPos;
|
IndexData[IndexPos ] = VertexPos;
|
||||||
IndexData[IndexPos + 1] = VertexPos + 1;
|
IndexData[IndexPos + 1] = VertexPos + 1;
|
||||||
IndexData[IndexPos + 2] = VertexPos + 2;
|
IndexData[IndexPos + 2] = VertexPos + 2;
|
||||||
|
@ -2894,6 +2903,7 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
||||||
IndexData[IndexPos + 4] = VertexPos + 2;
|
IndexData[IndexPos + 4] = VertexPos + 2;
|
||||||
IndexData[IndexPos + 5] = VertexPos + 3;
|
IndexData[IndexPos + 5] = VertexPos + 3;
|
||||||
|
|
||||||
|
// Batch the quad.
|
||||||
QuadBatchPos++;
|
QuadBatchPos++;
|
||||||
VertexPos += 4;
|
VertexPos += 4;
|
||||||
IndexPos += 6;
|
IndexPos += 6;
|
||||||
|
|
|
@ -248,7 +248,7 @@ public:
|
||||||
void DrawBlendingRect ();
|
void DrawBlendingRect ();
|
||||||
FNativeTexture *CreateTexture (FTexture *gametex, bool wrapping);
|
FNativeTexture *CreateTexture (FTexture *gametex, bool wrapping);
|
||||||
FNativePalette *CreatePalette (FRemapTable *remap);
|
FNativePalette *CreatePalette (FRemapTable *remap);
|
||||||
void STACK_ARGS DrawTextureV (FTexture *img, int x, int y, uint32 tag, va_list tags);
|
void STACK_ARGS DrawTextureV (FTexture *img, double x, double y, uint32 tag, va_list tags);
|
||||||
void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color);
|
void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color);
|
||||||
void Dim (PalEntry color, float amount, int x1, int y1, int w, int h);
|
void Dim (PalEntry color, float amount, int x1, int y1, int w, int h);
|
||||||
void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin);
|
void FlatFill (int left, int top, int right, int bottom, FTexture *src, bool local_origin);
|
||||||
|
|
746
zdoom.vcproj
746
zdoom.vcproj
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue