mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-14 08:30:49 +00:00
- narrowing down the public interface of the texture class
Cannot refactor if the entire class is this wide open to everything. Not complete yet, doesn't fully compile!
This commit is contained in:
parent
e83af15907
commit
6eab4a882c
74 changed files with 608 additions and 518 deletions
|
@ -1198,8 +1198,8 @@ static void AM_ScrollParchment (double dmapx, double dmapy)
|
||||||
|
|
||||||
if (backtex != NULL)
|
if (backtex != NULL)
|
||||||
{
|
{
|
||||||
int pwidth = backtex->GetWidth();
|
int pwidth = backtex->GetDisplayWidth();
|
||||||
int pheight = backtex->GetHeight();
|
int pheight = backtex->GetDisplayHeight();
|
||||||
|
|
||||||
while(mapxstart > 0)
|
while(mapxstart > 0)
|
||||||
mapxstart -= pwidth;
|
mapxstart -= pwidth;
|
||||||
|
@ -1692,8 +1692,8 @@ void AM_clearFB (const AMColor &color)
|
||||||
FTexture *backtex = TexMan[mapback];
|
FTexture *backtex = TexMan[mapback];
|
||||||
if (backtex != NULL)
|
if (backtex != NULL)
|
||||||
{
|
{
|
||||||
int pwidth = backtex->GetWidth();
|
int pwidth = backtex->GetDisplayWidth();
|
||||||
int pheight = backtex->GetHeight();
|
int pheight = backtex->GetDisplayHeight();
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
//blit the automap background to the screen.
|
//blit the automap background to the screen.
|
||||||
|
@ -2212,8 +2212,7 @@ void AM_drawSubsectors()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the polygon.
|
// Draw the polygon.
|
||||||
FTexture *pic = TexMan(maptex);
|
if (maptex.isValid())
|
||||||
if (pic != nullptr && pic->UseType != ETextureType::Null)
|
|
||||||
{
|
{
|
||||||
// Hole filling "subsectors" are not necessarily convex so they require real triangulation.
|
// Hole filling "subsectors" are not necessarily convex so they require real triangulation.
|
||||||
// These things are extremely rare so performance is secondary here.
|
// These things are extremely rare so performance is secondary here.
|
||||||
|
@ -3116,7 +3115,7 @@ void AM_drawThings ()
|
||||||
static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
|
static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
|
||||||
INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle)
|
INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle)
|
||||||
{
|
{
|
||||||
if (tex == NULL || tex->UseType == ETextureType::Null)
|
if (tex == NULL || !tex->isValid())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3125,8 +3124,8 @@ static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
|
||||||
AM_rotatePoint (&x, &y);
|
AM_rotatePoint (&x, &y);
|
||||||
}
|
}
|
||||||
screen->DrawTexture (tex, CXMTOF(x) + f_x, CYMTOF(y) + yadjust + f_y,
|
screen->DrawTexture (tex, CXMTOF(x) + f_x, CYMTOF(y) + yadjust + f_y,
|
||||||
DTA_DestWidthF, tex->GetScaledWidthDouble() * CleanXfac * xscale,
|
DTA_DestWidthF, tex->GetDisplayWidthDouble() * CleanXfac * xscale,
|
||||||
DTA_DestHeightF, tex->GetScaledHeightDouble() * CleanYfac * yscale,
|
DTA_DestHeightF, tex->GetDisplayHeightDouble() * CleanYfac * yscale,
|
||||||
DTA_ClipTop, f_y,
|
DTA_ClipTop, f_y,
|
||||||
DTA_ClipBottom, f_y + f_h,
|
DTA_ClipBottom, f_y + f_h,
|
||||||
DTA_ClipLeft, f_x,
|
DTA_ClipLeft, f_x,
|
||||||
|
@ -3185,9 +3184,9 @@ void AM_drawAuthorMarkers ()
|
||||||
if (mark->picnum.isValid())
|
if (mark->picnum.isValid())
|
||||||
{
|
{
|
||||||
tex = TexMan(mark->picnum);
|
tex = TexMan(mark->picnum);
|
||||||
if (tex->Rotations != 0xFFFF)
|
if (tex->GetRotations() != 0xFFFF)
|
||||||
{
|
{
|
||||||
spriteframe_t *sprframe = &SpriteFrames[tex->Rotations];
|
spriteframe_t *sprframe = &SpriteFrames[tex->GetRotations()];
|
||||||
picnum = sprframe->Texture[0];
|
picnum = sprframe->Texture[0];
|
||||||
flip = sprframe->Flip & 1;
|
flip = sprframe->Flip & 1;
|
||||||
tex = TexMan[picnum];
|
tex = TexMan[picnum];
|
||||||
|
|
|
@ -835,15 +835,15 @@ void D_Display ()
|
||||||
FString pstring = "By ";
|
FString pstring = "By ";
|
||||||
|
|
||||||
tex = TexMan(gameinfo.PauseSign);
|
tex = TexMan(gameinfo.PauseSign);
|
||||||
x = (SCREENWIDTH - tex->GetScaledWidth() * CleanXfac)/2 +
|
x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 +
|
||||||
tex->GetScaledLeftOffset(0) * CleanXfac;
|
tex->GetDisplayLeftOffset() * CleanXfac;
|
||||||
screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE);
|
screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE);
|
||||||
if (paused && multiplayer)
|
if (paused && multiplayer)
|
||||||
{
|
{
|
||||||
pstring += players[paused - 1].userinfo.GetName();
|
pstring += players[paused - 1].userinfo.GetName();
|
||||||
screen->DrawText(SmallFont, CR_RED,
|
screen->DrawText(SmallFont, CR_RED,
|
||||||
(screen->GetWidth() - SmallFont->StringWidth(pstring)*CleanXfac) / 2,
|
(screen->GetWidth() - SmallFont->StringWidth(pstring)*CleanXfac) / 2,
|
||||||
(tex->GetScaledHeight() * CleanYfac) + 4, pstring, DTA_CleanNoMove, true, TAG_DONE);
|
(tex->GetDisplayHeight() * CleanYfac) + 4, pstring, DTA_CleanNoMove, true, TAG_DONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -856,7 +856,7 @@ void D_Display ()
|
||||||
if (picnum.isValid())
|
if (picnum.isValid())
|
||||||
{
|
{
|
||||||
FTexture *tex = TexMan[picnum];
|
FTexture *tex = TexMan[picnum];
|
||||||
screen->DrawTexture (tex, 160 - tex->GetScaledWidth()/2, 100 - tex->GetScaledHeight()/2,
|
screen->DrawTexture (tex, 160 - tex->GetDisplayWidth()/2, 100 - tex->GetDisplayHeight()/2,
|
||||||
DTA_320x200, true, TAG_DONE);
|
DTA_320x200, true, TAG_DONE);
|
||||||
}
|
}
|
||||||
NoWipe = 10;
|
NoWipe = 10;
|
||||||
|
|
|
@ -304,8 +304,8 @@ bool Wiper_Melt::Run(int ticks)
|
||||||
// Only draw for the final tick.
|
// Only draw for the final tick.
|
||||||
// No need for optimization. Wipes won't ever be drawn with anything else.
|
// No need for optimization. Wipes won't ever be drawn with anything else.
|
||||||
|
|
||||||
int w = startScreen->GetWidth();
|
int w = startScreen->GetDisplayWidth();
|
||||||
int h = startScreen->GetHeight();
|
int h = startScreen->GetDisplayHeight();
|
||||||
dpt.x = i * w / WIDTH;
|
dpt.x = i * w / WIDTH;
|
||||||
dpt.y = MAX(0, y[i] * h / HEIGHT);
|
dpt.y = MAX(0, y[i] * h / HEIGHT);
|
||||||
rect.left = dpt.x;
|
rect.left = dpt.x;
|
||||||
|
|
|
@ -1904,7 +1904,7 @@ void FParser::SF_FloorTexture(void)
|
||||||
|
|
||||||
t_return.type = svt_string;
|
t_return.type = svt_string;
|
||||||
FTexture * tex = TexMan[sector->GetTexture(sector_t::floor)];
|
FTexture * tex = TexMan[sector->GetTexture(sector_t::floor)];
|
||||||
t_return.string = tex? tex->Name : "";
|
t_return.string = tex? tex->GetName() : "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1994,7 +1994,7 @@ void FParser::SF_CeilingTexture(void)
|
||||||
|
|
||||||
t_return.type = svt_string;
|
t_return.type = svt_string;
|
||||||
FTexture * tex = TexMan[sector->GetTexture(sector_t::ceiling)];
|
FTexture * tex = TexMan[sector->GetTexture(sector_t::ceiling)];
|
||||||
t_return.string = tex? tex->Name : "";
|
t_return.string = tex? tex->GetName() : "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ FTextureID DBaseDecal::StickToWall (side_t *wall, double x, double y, F3DFloor *
|
||||||
|
|
||||||
FTexture *texture = TexMan[tex];
|
FTexture *texture = TexMan[tex];
|
||||||
|
|
||||||
if (texture == NULL || texture->bNoDecals)
|
if (texture == NULL || texture->allowNoDecals())
|
||||||
{
|
{
|
||||||
return FNullTextureID();
|
return FNullTextureID();
|
||||||
}
|
}
|
||||||
|
@ -497,10 +497,10 @@ void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, double x, doub
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dwidth = tex->GetWidth ();
|
int dwidth = tex->GetDisplayWidth ();
|
||||||
|
|
||||||
DecalWidth = dwidth * ScaleX;
|
DecalWidth = dwidth * ScaleX;
|
||||||
DecalLeft = tex->GetLeftOffset(0) * ScaleX;
|
DecalLeft = tex->GetDisplayLeftOffset() * ScaleX;
|
||||||
DecalRight = DecalWidth - DecalLeft;
|
DecalRight = DecalWidth - DecalLeft;
|
||||||
SpreadSource = this;
|
SpreadSource = this;
|
||||||
SpreadTemplate = tpl;
|
SpreadTemplate = tpl;
|
||||||
|
|
|
@ -937,7 +937,7 @@ CCMD(listlights)
|
||||||
if (dl->target)
|
if (dl->target)
|
||||||
{
|
{
|
||||||
FTextureID spr = sprites[dl->target->sprite].GetSpriteFrame(dl->target->frame, 0, 0., nullptr);
|
FTextureID spr = sprites[dl->target->sprite].GetSpriteFrame(dl->target->frame, 0, 0., nullptr);
|
||||||
Printf(", frame = %s ", TexMan[spr]->Name.GetChars());
|
Printf(", frame = %s ", TexMan[spr]->GetName().GetChars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1188,12 +1188,12 @@ public:
|
||||||
|
|
||||||
if((offsetflags & SBarInfoCommand::CENTER) == SBarInfoCommand::CENTER)
|
if((offsetflags & SBarInfoCommand::CENTER) == SBarInfoCommand::CENTER)
|
||||||
{
|
{
|
||||||
if (forceWidth < 0) dx -= (texture->GetScaledWidthDouble()/2.0)-texture->GetScaledLeftOffsetDouble(0);
|
if (forceWidth < 0) dx -= (texture->GetDisplayWidthDouble()/2.0)-texture->GetDisplayLeftOffsetDouble();
|
||||||
else dx -= forceWidth*(0.5-(texture->GetScaledLeftOffsetDouble(0)/texture->GetScaledWidthDouble()));
|
else dx -= forceWidth*(0.5-(texture->GetDisplayLeftOffsetDouble()/texture->GetDisplayWidthDouble()));
|
||||||
//Unoptimalized ^^formula is dx -= forceWidth/2.0-(texture->GetScaledLeftOffsetDouble()*forceWidth/texture->GetScaledWidthDouble());
|
//Unoptimalized ^^formula is dx -= forceWidth/2.0-(texture->GetScaledLeftOffsetDouble()*forceWidth/texture->GetDisplayWidthDouble());
|
||||||
|
|
||||||
if (forceHeight < 0) dy -= (texture->GetScaledHeightDouble()/2.0)-texture->GetScaledTopOffsetDouble(0);
|
if (forceHeight < 0) dy -= (texture->GetDisplayHeightDouble()/2.0)-texture->GetDisplayTopOffsetDouble();
|
||||||
else dy -= forceHeight*(0.5-(texture->GetScaledTopOffsetDouble(0)/texture->GetScaledHeightDouble()));
|
else dy -= forceHeight*(0.5-(texture->GetDisplayTopOffsetDouble()/texture->GetDisplayHeightDouble()));
|
||||||
}
|
}
|
||||||
|
|
||||||
dx += xOffset;
|
dx += xOffset;
|
||||||
|
@ -1202,12 +1202,12 @@ public:
|
||||||
if(!fullScreenOffsets)
|
if(!fullScreenOffsets)
|
||||||
{
|
{
|
||||||
double tmp = 0;
|
double tmp = 0;
|
||||||
w = forceWidth < 0 ? texture->GetScaledWidthDouble() : forceWidth;
|
w = forceWidth < 0 ? texture->GetDisplayWidthDouble() : forceWidth;
|
||||||
h = forceHeight < 0 ? texture->GetScaledHeightDouble() : forceHeight;
|
h = forceHeight < 0 ? texture->GetDisplayHeightDouble() : forceHeight;
|
||||||
double dcx = clip[0] == 0 ? 0 : dx + clip[0] - texture->GetScaledLeftOffsetDouble(0);
|
double dcx = clip[0] == 0 ? 0 : dx + clip[0] - texture->GetDisplayLeftOffsetDouble();
|
||||||
double dcy = clip[1] == 0 ? 0 : dy + clip[1] - texture->GetScaledTopOffsetDouble(0);
|
double dcy = clip[1] == 0 ? 0 : dy + clip[1] - texture->GetDisplayTopOffsetDouble();
|
||||||
double dcr = clip[2] == 0 ? INT_MAX : dx + w - clip[2] - texture->GetScaledLeftOffsetDouble(0);
|
double dcr = clip[2] == 0 ? INT_MAX : dx + w - clip[2] - texture->GetDisplayLeftOffsetDouble();
|
||||||
double dcb = clip[3] == 0 ? INT_MAX : dy + h - clip[3] - texture->GetScaledTopOffsetDouble(0);
|
double dcb = clip[3] == 0 ? INT_MAX : dy + h - clip[3] - texture->GetDisplayTopOffsetDouble();
|
||||||
|
|
||||||
if(clip[0] != 0 || clip[1] != 0)
|
if(clip[0] != 0 || clip[1] != 0)
|
||||||
{
|
{
|
||||||
|
@ -1271,8 +1271,8 @@ public:
|
||||||
bool xright = *x < 0 && !x.RelCenter();
|
bool xright = *x < 0 && !x.RelCenter();
|
||||||
bool ybot = *y < 0 && !y.RelCenter();
|
bool ybot = *y < 0 && !y.RelCenter();
|
||||||
|
|
||||||
w = (forceWidth < 0 ? texture->GetScaledWidthDouble() : forceWidth);
|
w = (forceWidth < 0 ? texture->GetDisplayWidthDouble() : forceWidth);
|
||||||
h = (forceHeight < 0 ? texture->GetScaledHeightDouble() : forceHeight);
|
h = (forceHeight < 0 ? texture->GetDisplayHeightDouble() : forceHeight);
|
||||||
if(vid_fps && rx < 0 && ry >= 0)
|
if(vid_fps && rx < 0 && ry >= 0)
|
||||||
ry += 10;
|
ry += 10;
|
||||||
|
|
||||||
|
@ -1289,10 +1289,10 @@ public:
|
||||||
// Check for clipping
|
// Check for clipping
|
||||||
if(clip[0] != 0 || clip[1] != 0 || clip[2] != 0 || clip[3] != 0)
|
if(clip[0] != 0 || clip[1] != 0 || clip[2] != 0 || clip[3] != 0)
|
||||||
{
|
{
|
||||||
rcx = clip[0] == 0 ? 0 : rx+((clip[0] - texture->GetScaledLeftOffsetDouble(0))*Scale.X);
|
rcx = clip[0] == 0 ? 0 : rx+((clip[0] - texture->GetDisplayLeftOffsetDouble())*Scale.X);
|
||||||
rcy = clip[1] == 0 ? 0 : ry+((clip[1] - texture->GetScaledTopOffsetDouble(0))*Scale.Y);
|
rcy = clip[1] == 0 ? 0 : ry+((clip[1] - texture->GetDisplayTopOffsetDouble())*Scale.Y);
|
||||||
rcr = clip[2] == 0 ? INT_MAX : rx+w-((clip[2] + texture->GetScaledLeftOffsetDouble(0))*Scale.X);
|
rcr = clip[2] == 0 ? INT_MAX : rx+w-((clip[2] + texture->GetDisplayLeftOffsetDouble())*Scale.X);
|
||||||
rcb = clip[3] == 0 ? INT_MAX : ry+h-((clip[3] + texture->GetScaledTopOffsetDouble(0))*Scale.Y);
|
rcb = clip[3] == 0 ? INT_MAX : ry+h-((clip[3] + texture->GetDisplayTopOffsetDouble())*Scale.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(clearDontDraw)
|
if(clearDontDraw)
|
||||||
|
@ -1389,13 +1389,13 @@ public:
|
||||||
int character = (unsigned char)*str;
|
int character = (unsigned char)*str;
|
||||||
|
|
||||||
if (script->spacingCharacter == '\0') //If we are monospaced lets use the offset
|
if (script->spacingCharacter == '\0') //If we are monospaced lets use the offset
|
||||||
ax += (c->GetLeftOffset(0) + 1); //ignore x offsets since we adapt to character size
|
ax += (c->GetDisplayLeftOffset() + 1); //ignore x offsets since we adapt to character size
|
||||||
|
|
||||||
double rx, ry, rw, rh;
|
double rx, ry, rw, rh;
|
||||||
rx = ax + xOffset;
|
rx = ax + xOffset;
|
||||||
ry = ay + yOffset;
|
ry = ay + yOffset;
|
||||||
rw = c->GetScaledWidthDouble();
|
rw = c->GetDisplayWidthDouble();
|
||||||
rh = c->GetScaledHeightDouble();
|
rh = c->GetDisplayHeightDouble();
|
||||||
|
|
||||||
if(script->spacingCharacter != '\0')
|
if(script->spacingCharacter != '\0')
|
||||||
{
|
{
|
||||||
|
@ -1453,7 +1453,7 @@ public:
|
||||||
DTA_Alpha, Alpha,
|
DTA_Alpha, Alpha,
|
||||||
TAG_DONE);
|
TAG_DONE);
|
||||||
if (script->spacingCharacter == '\0')
|
if (script->spacingCharacter == '\0')
|
||||||
ax += width + spacing - (c->GetLeftOffset(0) + 1);
|
ax += width + spacing - (c->GetDisplayLeftOffsetDouble() + 1);
|
||||||
else //width gets changed at the call to GetChar()
|
else //width gets changed at the call to GetChar()
|
||||||
ax += font->GetCharWidth((unsigned char) script->spacingCharacter) + spacing;
|
ax += font->GetCharWidth((unsigned char) script->spacingCharacter) + spacing;
|
||||||
str++;
|
str++;
|
||||||
|
|
|
@ -69,8 +69,8 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
||||||
{
|
{
|
||||||
double scale1, scale2;
|
double scale1, scale2;
|
||||||
scale1 = scale2 = 1.0f;
|
scale1 = scale2 = 1.0f;
|
||||||
double texwidth = (int) (texture->GetScaledWidthDouble()*spawnScaleX);
|
double texwidth = (int) (texture->GetDisplayWidthDouble()*spawnScaleX);
|
||||||
double texheight = (int) (texture->GetScaledHeightDouble()*spawnScaleY);
|
double texheight = (int) (texture->GetDisplayHeightDouble()*spawnScaleY);
|
||||||
|
|
||||||
if (w != -1 && (w<texwidth || (flags & DI_FORCESCALE)))
|
if (w != -1 && (w<texwidth || (flags & DI_FORCESCALE)))
|
||||||
{
|
{
|
||||||
|
@ -93,8 +93,8 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
||||||
}
|
}
|
||||||
else if (applyscale)
|
else if (applyscale)
|
||||||
{
|
{
|
||||||
w=(int) (texture->GetScaledWidthDouble()*spawnScaleX);
|
w=(int) (texture->GetDisplayWidthDouble()*spawnScaleX);
|
||||||
h=(int) (texture->GetScaledHeightDouble()*spawnScaleY);
|
h=(int) (texture->GetDisplayHeightDouble()*spawnScaleY);
|
||||||
}
|
}
|
||||||
statusBar->DrawGraphic(texture, imgx, imgy, block->XOffset(), block->YOffset(), frameAlpha, block->FullScreenOffsets(),
|
statusBar->DrawGraphic(texture, imgx, imgy, block->XOffset(), block->YOffset(), frameAlpha, block->FullScreenOffsets(),
|
||||||
translatable, false, offset, false, w, h);
|
translatable, false, offset, false, w, h);
|
||||||
|
@ -300,7 +300,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
||||||
|
|
||||||
if (flags & DI_ALTERNATEONFAIL)
|
if (flags & DI_ALTERNATEONFAIL)
|
||||||
{
|
{
|
||||||
SetTruth(texture == NULL || texture->UseType == ETextureType::Null, block, statusBar);
|
SetTruth(texture == NULL || !texture->isValid(), block, statusBar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
|
@ -2266,11 +2266,11 @@ class CommandDrawInventoryBar : public SBarInfoCommand
|
||||||
int spacing;
|
int spacing;
|
||||||
if (!vertical)
|
if (!vertical)
|
||||||
{
|
{
|
||||||
spacing = box->GetScaledWidth();
|
spacing = box->GetDisplayWidth();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
spacing = box->GetScaledHeight();
|
spacing = box->GetDisplayHeight();
|
||||||
}
|
}
|
||||||
return spacing + ((style != STYLE_Strife) ? 1 : -1);
|
return spacing + ((style != STYLE_Strife) ? 1 : -1);
|
||||||
}
|
}
|
||||||
|
@ -2370,21 +2370,21 @@ class CommandDrawKeyBar : public SBarInfoCommand
|
||||||
if(!vertical)
|
if(!vertical)
|
||||||
{
|
{
|
||||||
statusBar->DrawGraphic(TexMan(item->TextureIDVar(NAME_Icon)), x+slotOffset, y+rowOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
statusBar->DrawGraphic(TexMan(item->TextureIDVar(NAME_Icon)), x+slotOffset, y+rowOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||||
rowWidth = rowIconSize == -1 ? TexMan(item->TextureIDVar(NAME_Icon))->GetScaledHeight()+2 : rowIconSize;
|
rowWidth = rowIconSize == -1 ? TexMan(item->TextureIDVar(NAME_Icon))->GetDisplayHeight()+2 : rowIconSize;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
statusBar->DrawGraphic(TexMan(item->TextureIDVar(NAME_Icon)), x+rowOffset, y+slotOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
statusBar->DrawGraphic(TexMan(item->TextureIDVar(NAME_Icon)), x+rowOffset, y+slotOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||||
rowWidth = rowIconSize == -1 ? TexMan(item->TextureIDVar(NAME_Icon))->GetScaledWidth()+2 : rowIconSize;
|
rowWidth = rowIconSize == -1 ? TexMan(item->TextureIDVar(NAME_Icon))->GetDisplayWidth()+2 : rowIconSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If cmd.special is -1 then the slot size is auto detected
|
// If cmd.special is -1 then the slot size is auto detected
|
||||||
if(iconSize == -1)
|
if(iconSize == -1)
|
||||||
{
|
{
|
||||||
if(!vertical)
|
if(!vertical)
|
||||||
slotOffset += (reverse ? -1 : 1) * (TexMan(item->TextureIDVar(NAME_Icon))->GetScaledWidth() + 2);
|
slotOffset += (reverse ? -1 : 1) * (TexMan(item->TextureIDVar(NAME_Icon))->GetDisplayWidth() + 2);
|
||||||
else
|
else
|
||||||
slotOffset += (reverse ? -1 : 1) * (TexMan(item->TextureIDVar(NAME_Icon))->GetScaledHeight() + 2);
|
slotOffset += (reverse ? -1 : 1) * (TexMan(item->TextureIDVar(NAME_Icon))->GetDisplayHeight() + 2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
slotOffset += (reverse ? -iconSize : iconSize);
|
slotOffset += (reverse ? -iconSize : iconSize);
|
||||||
|
@ -2504,7 +2504,7 @@ class CommandDrawBar : public SBarInfoCommand
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Draw background
|
// Draw background
|
||||||
if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight())
|
if (bg != NULL && bg->GetDisplayWidth() == fg->GetDisplayWidth() && bg->GetDisplayHeight() == fg->GetDisplayHeight())
|
||||||
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||||
else
|
else
|
||||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, nulclip, true);
|
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, nulclip, true);
|
||||||
|
@ -2513,7 +2513,7 @@ class CommandDrawBar : public SBarInfoCommand
|
||||||
// {cx, cy, cr, cb}
|
// {cx, cy, cr, cb}
|
||||||
double Clip[4] = {0, 0, 0, 0};
|
double Clip[4] = {0, 0, 0, 0};
|
||||||
|
|
||||||
int sizeOfImage = (horizontal ? fg->GetScaledWidth()-border*2 : fg->GetScaledHeight()-border*2);
|
int sizeOfImage = (horizontal ? fg->GetDisplayWidth()-border*2 : fg->GetDisplayHeight()-border*2);
|
||||||
Clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - sizeOfImage *value;
|
Clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - sizeOfImage *value;
|
||||||
// Draw background
|
// Draw background
|
||||||
if(border != 0)
|
if(border != 0)
|
||||||
|
@ -2521,7 +2521,7 @@ class CommandDrawBar : public SBarInfoCommand
|
||||||
for(unsigned int i = 0;i < 4;i++)
|
for(unsigned int i = 0;i < 4;i++)
|
||||||
Clip[i] += border;
|
Clip[i] += border;
|
||||||
|
|
||||||
if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight())
|
if (bg != NULL && bg->GetDisplayWidth() == fg->GetDisplayWidth() && bg->GetDisplayHeight() == fg->GetDisplayHeight())
|
||||||
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip);
|
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip);
|
||||||
else
|
else
|
||||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip, true);
|
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip, true);
|
||||||
|
@ -2802,7 +2802,7 @@ class CommandDrawBar : public SBarInfoCommand
|
||||||
// [BL] Since we used a percentage (in order to get the most fluid animation)
|
// [BL] Since we used a percentage (in order to get the most fluid animation)
|
||||||
// we need to establish a cut off point so the last pixel won't hang as the animation slows
|
// we need to establish a cut off point so the last pixel won't hang as the animation slows
|
||||||
if(pixel == -1 && statusBar->Images[foreground])
|
if(pixel == -1 && statusBar->Images[foreground])
|
||||||
pixel = MAX(1 / 65536., 1./statusBar->Images[foreground]->GetWidth());
|
pixel = MAX(1 / 65536., 1./statusBar->Images[foreground]->GetDisplayWidth());
|
||||||
|
|
||||||
if(fabs(drawValue - value) < pixel)
|
if(fabs(drawValue - value) < pixel)
|
||||||
drawValue = value;
|
drawValue = value;
|
||||||
|
@ -3115,7 +3115,7 @@ class CommandDrawGem : public SBarInfoCommand
|
||||||
SBarInfoCoordinate drawY = y;
|
SBarInfoCoordinate drawY = y;
|
||||||
if(wiggle && drawValue != goalValue) // Should only wiggle when the value doesn't equal what is being drawn.
|
if(wiggle && drawValue != goalValue) // Should only wiggle when the value doesn't equal what is being drawn.
|
||||||
drawY += chainWiggle;
|
drawY += chainWiggle;
|
||||||
int chainWidth = chainImg->GetScaledWidth();
|
int chainWidth = chainImg->GetDisplayWidth();
|
||||||
int offset = (int) (((double) (chainWidth-leftPadding-rightPadding)/100)*drawValue);
|
int offset = (int) (((double) (chainWidth-leftPadding-rightPadding)/100)*drawValue);
|
||||||
statusBar->DrawGraphic(chainImg, x+(offset%chainSize), drawY, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
statusBar->DrawGraphic(chainImg, x+(offset%chainSize), drawY, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||||
if(gemImg != NULL)
|
if(gemImg != NULL)
|
||||||
|
|
|
@ -820,8 +820,8 @@ void DBaseStatusBar::RefreshBackground () const
|
||||||
FTexture *p = TexMan[gameinfo.Border.b];
|
FTexture *p = TexMan[gameinfo.Border.b];
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
{
|
{
|
||||||
screen->FlatFill(0, y, x, y + p->GetHeight(), p, true);
|
screen->FlatFill(0, y, x, y + p->GetDisplayHeight(), p, true);
|
||||||
screen->FlatFill(x2, y, SCREENWIDTH, y + p->GetHeight(), p, true);
|
screen->FlatFill(x2, y, SCREENWIDTH, y + p->GetDisplayHeight(), p, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -864,8 +864,8 @@ void DBaseStatusBar::DrawCrosshair ()
|
||||||
{
|
{
|
||||||
size *= CrosshairSize;
|
size *= CrosshairSize;
|
||||||
}
|
}
|
||||||
w = int(CrosshairImage->GetWidth() * size);
|
w = int(CrosshairImage->GetDisplayWidth() * size);
|
||||||
h = int(CrosshairImage->GetHeight() * size);
|
h = int(CrosshairImage->GetDisplayHeight() * size);
|
||||||
|
|
||||||
if (crosshairhealth)
|
if (crosshairhealth)
|
||||||
{
|
{
|
||||||
|
@ -1325,8 +1325,8 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla
|
||||||
|
|
||||||
FTexture *tex = (flags & DI_DONTANIMATE)? TexMan[texture] : TexMan(texture);
|
FTexture *tex = (flags & DI_DONTANIMATE)? TexMan[texture] : TexMan(texture);
|
||||||
|
|
||||||
double texwidth = tex->GetScaledWidthDouble() * scaleX;
|
double texwidth = tex->GetDisplayWidthDouble() * scaleX;
|
||||||
double texheight = tex->GetScaledHeightDouble() * scaleY;
|
double texheight = tex->GetDisplayHeightDouble() * scaleY;
|
||||||
|
|
||||||
if (boxwidth > 0 || boxheight > 0)
|
if (boxwidth > 0 || boxheight > 0)
|
||||||
{
|
{
|
||||||
|
@ -1378,14 +1378,14 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla
|
||||||
{
|
{
|
||||||
case DI_ITEM_HCENTER: x -= boxwidth / 2; break;
|
case DI_ITEM_HCENTER: x -= boxwidth / 2; break;
|
||||||
case DI_ITEM_RIGHT: x -= boxwidth; break;
|
case DI_ITEM_RIGHT: x -= boxwidth; break;
|
||||||
case DI_ITEM_HOFFSET: x -= tex->GetScaledLeftOffsetDouble(0) * boxwidth / texwidth; break;
|
case DI_ITEM_HOFFSET: x -= tex->GetDisplayLeftOffsetDouble() * boxwidth / texwidth; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (flags & DI_ITEM_VMASK)
|
switch (flags & DI_ITEM_VMASK)
|
||||||
{
|
{
|
||||||
case DI_ITEM_VCENTER: y -= boxheight / 2; break;
|
case DI_ITEM_VCENTER: y -= boxheight / 2; break;
|
||||||
case DI_ITEM_BOTTOM: y -= boxheight; break;
|
case DI_ITEM_BOTTOM: y -= boxheight; break;
|
||||||
case DI_ITEM_VOFFSET: y -= tex->GetScaledTopOffsetDouble(0) * boxheight / texheight; break;
|
case DI_ITEM_VOFFSET: y -= tex->GetDisplayTopOffsetDouble() * boxheight / texheight; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fullscreenOffsets)
|
if (!fullscreenOffsets)
|
||||||
|
@ -1520,13 +1520,13 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!monospaced) //If we are monospaced lets use the offset
|
if (!monospaced) //If we are monospaced lets use the offset
|
||||||
x += (c->GetLeftOffset(0) + 1); //ignore x offsets since we adapt to character size
|
x += (c->GetDisplayLeftOffsetDouble() + 1); //ignore x offsets since we adapt to character size
|
||||||
|
|
||||||
double rx, ry, rw, rh;
|
double rx, ry, rw, rh;
|
||||||
rx = x + drawOffset.X;
|
rx = x + drawOffset.X;
|
||||||
ry = y + drawOffset.Y;
|
ry = y + drawOffset.Y;
|
||||||
rw = c->GetScaledWidthDouble();
|
rw = c->GetDisplayWidthDouble();
|
||||||
rh = c->GetScaledHeightDouble();
|
rh = c->GetDisplayHeightDouble();
|
||||||
|
|
||||||
if (!fullscreenOffsets)
|
if (!fullscreenOffsets)
|
||||||
{
|
{
|
||||||
|
@ -1560,7 +1560,7 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d
|
||||||
TAG_DONE);
|
TAG_DONE);
|
||||||
|
|
||||||
if (!monospaced)
|
if (!monospaced)
|
||||||
x += width + spacing - (c->GetLeftOffset(0) + 1);
|
x += width + spacing - (c->GetDisplayLeftOffsetDouble() + 1);
|
||||||
else
|
else
|
||||||
x += spacing;
|
x += spacing;
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,7 +303,8 @@ void FGLRenderState::Apply()
|
||||||
|
|
||||||
void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader)
|
void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader)
|
||||||
{
|
{
|
||||||
if (mat->tex->bHasCanvas)
|
#if 0
|
||||||
|
if (mat->tex->isHardwareCanvas())
|
||||||
{
|
{
|
||||||
mTempTM = TM_OPAQUE;
|
mTempTM = TM_OPAQUE;
|
||||||
}
|
}
|
||||||
|
@ -317,8 +318,8 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
|
||||||
|
|
||||||
auto tex = mat->tex;
|
auto tex = mat->tex;
|
||||||
if (tex->UseType == ETextureType::SWCanvas) clampmode = CLAMP_NOFILTER;
|
if (tex->UseType == ETextureType::SWCanvas) clampmode = CLAMP_NOFILTER;
|
||||||
if (tex->bHasCanvas) clampmode = CLAMP_CAMTEX;
|
if (tex->sHardwareCanvas()) clampmode = CLAMP_CAMTEX;
|
||||||
else if ((tex->bWarped || tex->shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
|
else if ((tex->isWarped() || tex->shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
|
||||||
|
|
||||||
// avoid rebinding the same texture multiple times.
|
// avoid rebinding the same texture multiple times.
|
||||||
if (mat == lastMaterial && lastClamp == clampmode && translation == lastTranslation) return;
|
if (mat == lastMaterial && lastClamp == clampmode && translation == lastTranslation) return;
|
||||||
|
@ -330,7 +331,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
|
||||||
int maxbound = 0;
|
int maxbound = 0;
|
||||||
|
|
||||||
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
|
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
|
||||||
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && tex->Scale.X == 1 && tex->Scale.Y == 1 && clampmode <= CLAMP_XY) ? CTF_CheckHires : 0;
|
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled() && clampmode <= CLAMP_XY) ? CTF_CheckHires : 0;
|
||||||
int numLayers = mat->GetLayers();
|
int numLayers = mat->GetLayers();
|
||||||
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0));
|
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0));
|
||||||
|
|
||||||
|
@ -350,6 +351,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
|
||||||
FHardwareTexture::Unbind(i);
|
FHardwareTexture::Unbind(i);
|
||||||
maxBoundMaterial = maxbound;
|
maxBoundMaterial = maxbound;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -217,7 +217,7 @@ void PostProcessShaderInstance::BindTextures()
|
||||||
|
|
||||||
FString name = pair->Value;
|
FString name = pair->Value;
|
||||||
FTexture *tex = TexMan(TexMan.CheckForTexture(name, ETextureType::Any));
|
FTexture *tex = TexMan(TexMan.CheckForTexture(name, ETextureType::Any));
|
||||||
if (tex && tex->UseType != ETextureType::Null)
|
if (tex && tex->isValid())
|
||||||
{
|
{
|
||||||
glUniform1i(location, textureUnit);
|
glUniform1i(location, textureUnit);
|
||||||
|
|
||||||
|
@ -225,16 +225,17 @@ void PostProcessShaderInstance::BindTextures()
|
||||||
auto it = mTextureHandles.find(tex);
|
auto it = mTextureHandles.find(tex);
|
||||||
if (it == mTextureHandles.end())
|
if (it == mTextureHandles.end())
|
||||||
{
|
{
|
||||||
FBitmap bitmap;
|
// Why does this completely circumvent the normal way of handling textures?
|
||||||
bitmap.Create(tex->GetWidth(), tex->GetHeight());
|
int width, height;
|
||||||
tex->CopyTrueColorPixels(&bitmap, 0, 0);
|
auto buffer = tex->CreateTexBuffer(0, width, height);
|
||||||
|
|
||||||
GLuint handle = 0;
|
GLuint handle = 0;
|
||||||
glGenTextures(1, &handle);
|
glGenTextures(1, &handle);
|
||||||
glBindTexture(GL_TEXTURE_2D, handle);
|
glBindTexture(GL_TEXTURE_2D, handle);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex->GetWidth(), tex->GetHeight(), 0, GL_BGRA, GL_UNSIGNED_BYTE, bitmap.GetPixels());
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
delete[] buffer;
|
||||||
mTextureHandles[tex] = handle;
|
mTextureHandles[tex] = handle;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -347,16 +347,16 @@ void OpenGLFrameBuffer::SetTextureFilterMode()
|
||||||
|
|
||||||
IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture(FTexture *tex)
|
IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture(FTexture *tex)
|
||||||
{
|
{
|
||||||
return new FHardwareTexture(tex->bNoCompress);
|
return new FHardwareTexture(true/*tex->bNoCompress*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
|
void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
|
||||||
{
|
{
|
||||||
auto tex = mat->tex;
|
auto tex = mat->tex;
|
||||||
if (tex->UseType == ETextureType::SWCanvas) return;
|
if (tex->isSWCanvas()) return;
|
||||||
|
|
||||||
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
|
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
|
||||||
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && tex->Scale.X == 1 && tex->Scale.Y == 1) ? CTF_CheckHires : 0;
|
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled()) ? CTF_CheckHires : 0;
|
||||||
int numLayers = mat->GetLayers();
|
int numLayers = mat->GetLayers();
|
||||||
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0));
|
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0));
|
||||||
|
|
||||||
|
@ -527,9 +527,9 @@ FTexture *OpenGLFrameBuffer::WipeStartScreen()
|
||||||
const auto &viewport = screen->mScreenViewport;
|
const auto &viewport = screen->mScreenViewport;
|
||||||
|
|
||||||
auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
|
auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
|
||||||
tex->SystemTexture[0]->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
|
tex->GetSystemTexture(0)->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
|
||||||
glFinish();
|
glFinish();
|
||||||
static_cast<FHardwareTexture*>(tex->SystemTexture[0])->Bind(0, false, false);
|
static_cast<FHardwareTexture*>(tex->GetSystemTexture(0))->Bind(0, false, false);
|
||||||
|
|
||||||
GLRenderer->mBuffers->BindCurrentFB();
|
GLRenderer->mBuffers->BindCurrentFB();
|
||||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height);
|
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height);
|
||||||
|
@ -549,9 +549,9 @@ FTexture *OpenGLFrameBuffer::WipeEndScreen()
|
||||||
GLRenderer->Flush();
|
GLRenderer->Flush();
|
||||||
const auto &viewport = screen->mScreenViewport;
|
const auto &viewport = screen->mScreenViewport;
|
||||||
auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
|
auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
|
||||||
tex->SystemTexture[0]->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
|
tex->GetSystemTexture(0)->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
|
||||||
glFinish();
|
glFinish();
|
||||||
static_cast<FHardwareTexture*>(tex->SystemTexture[0])->Bind(0, false, false);
|
static_cast<FHardwareTexture*>(tex->GetSystemTexture(0))->Bind(0, false, false);
|
||||||
GLRenderer->mBuffers->BindCurrentFB();
|
GLRenderer->mBuffers->BindCurrentFB();
|
||||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height);
|
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height);
|
||||||
return tex;
|
return tex;
|
||||||
|
|
|
@ -422,6 +422,7 @@ void FHardwareTexture::BindToFrameBuffer(int width, int height)
|
||||||
|
|
||||||
bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags)
|
bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
int usebright = false;
|
int usebright = false;
|
||||||
|
|
||||||
if (translation <= 0)
|
if (translation <= 0)
|
||||||
|
@ -445,7 +446,7 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i
|
||||||
// Create this texture
|
// Create this texture
|
||||||
unsigned char * buffer = nullptr;
|
unsigned char * buffer = nullptr;
|
||||||
|
|
||||||
if (!tex->bHasCanvas)
|
if (!tex->isHardwareCanvas())
|
||||||
{
|
{
|
||||||
buffer = tex->CreateTexBuffer(translation, w, h, flags | CTF_ProcessData);
|
buffer = tex->CreateTexBuffer(translation, w, h, flags | CTF_ProcessData);
|
||||||
}
|
}
|
||||||
|
@ -462,8 +463,9 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i
|
||||||
}
|
}
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
}
|
}
|
||||||
if (tex->bHasCanvas) static_cast<FCanvasTexture*>(tex)->NeedUpdate();
|
if (tex->isHardwareCanvas()) static_cast<FCanvasTexture*>(tex)->NeedUpdate();
|
||||||
GLRenderer->mSamplerManager->Bind(texunit, clampmode, 255);
|
GLRenderer->mSamplerManager->Bind(texunit, clampmode, 255);
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,14 +210,14 @@ void HU_GetPlayerWidths(int &maxnamewidth, int &maxscorewidth, int &maxiconheigh
|
||||||
if (players[i].mo->ScoreIcon.isValid())
|
if (players[i].mo->ScoreIcon.isValid())
|
||||||
{
|
{
|
||||||
FTexture *pic = TexMan[players[i].mo->ScoreIcon];
|
FTexture *pic = TexMan[players[i].mo->ScoreIcon];
|
||||||
width = pic->GetScaledWidth() - pic->GetScaledLeftOffset(0) + 2;
|
width = pic->GetDisplayWidth() - pic->GetDisplayLeftOffset() + 2;
|
||||||
if (width > maxscorewidth)
|
if (width > maxscorewidth)
|
||||||
{
|
{
|
||||||
maxscorewidth = width;
|
maxscorewidth = width;
|
||||||
}
|
}
|
||||||
// The icon's top offset does not count toward its height, because
|
// The icon's top offset does not count toward its height, because
|
||||||
// zdoom.pk3's standard Hexen class icons are designed that way.
|
// zdoom.pk3's standard Hexen class icons are designed that way.
|
||||||
int height = pic->GetScaledHeight() - pic->GetScaledTopOffset(0);
|
int height = pic->GetDisplayHeight() - pic->GetDisplayTopOffset();
|
||||||
if (height > maxiconheight)
|
if (height > maxiconheight)
|
||||||
{
|
{
|
||||||
maxiconheight = height;
|
maxiconheight = height;
|
||||||
|
@ -446,7 +446,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
|
||||||
if (teamplay && Teams[player->userinfo.GetTeam()].GetLogo().IsNotEmpty ())
|
if (teamplay && Teams[player->userinfo.GetTeam()].GetLogo().IsNotEmpty ())
|
||||||
{
|
{
|
||||||
FTexture *pic = TexMan[Teams[player->userinfo.GetTeam()].GetLogo().GetChars ()];
|
FTexture *pic = TexMan[Teams[player->userinfo.GetTeam()].GetLogo().GetChars ()];
|
||||||
screen->DrawTexture (pic, col1 - (pic->GetScaledWidth() + 2) * CleanXfac, y,
|
screen->DrawTexture (pic, col1 - (pic->GetDisplayWidth() + 2) * CleanXfac, y,
|
||||||
DTA_CleanNoMove, true, TAG_DONE);
|
DTA_CleanNoMove, true, TAG_DONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,7 +278,7 @@ void HWDrawInfo::AddLine (seg_t *seg, bool portalclip)
|
||||||
if (!seg->linedef->isVisualPortal())
|
if (!seg->linedef->isVisualPortal())
|
||||||
{
|
{
|
||||||
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::mid));
|
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::mid));
|
||||||
if (!tex || tex->UseType==ETextureType::Null)
|
if (!tex || !tex->isValid())
|
||||||
{
|
{
|
||||||
// nothing to do here!
|
// nothing to do here!
|
||||||
seg->linedef->validcount=validcount;
|
seg->linedef->validcount=validcount;
|
||||||
|
|
|
@ -118,7 +118,7 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
|
||||||
if (bs_ceilingheight1 <= fs_floorheight1 && bs_ceilingheight2 <= fs_floorheight2)
|
if (bs_ceilingheight1 <= fs_floorheight1 && bs_ceilingheight2 <= fs_floorheight2)
|
||||||
{
|
{
|
||||||
FTexture * tex = TexMan(sidedef->GetTexture(side_t::top));
|
FTexture * tex = TexMan(sidedef->GetTexture(side_t::top));
|
||||||
if (!tex || tex->UseType == ETextureType::Null) return false;
|
if (!tex || !tex->isValid()) return false;
|
||||||
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
||||||
frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false;
|
frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -127,7 +127,7 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
|
||||||
if (fs_ceilingheight1 <= bs_floorheight1 && fs_ceilingheight2 <= bs_floorheight2)
|
if (fs_ceilingheight1 <= bs_floorheight1 && fs_ceilingheight2 <= bs_floorheight2)
|
||||||
{
|
{
|
||||||
FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom));
|
FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom));
|
||||||
if (!tex || tex->UseType == ETextureType::Null) return false;
|
if (!tex || !tex->isValid()) return false;
|
||||||
|
|
||||||
// properly render skies (consider door "open" if both floors are sky):
|
// properly render skies (consider door "open" if both floors are sky):
|
||||||
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
||||||
|
@ -141,12 +141,12 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
|
||||||
if (bs_ceilingheight1 < fs_ceilingheight1 || bs_ceilingheight2 < fs_ceilingheight2)
|
if (bs_ceilingheight1 < fs_ceilingheight1 || bs_ceilingheight2 < fs_ceilingheight2)
|
||||||
{
|
{
|
||||||
FTexture * tex = TexMan(sidedef->GetTexture(side_t::top));
|
FTexture * tex = TexMan(sidedef->GetTexture(side_t::top));
|
||||||
if (!tex || tex->UseType == ETextureType::Null) return false;
|
if (!tex || !tex->isValid()) return false;
|
||||||
}
|
}
|
||||||
if (bs_floorheight1 > fs_floorheight1 || bs_floorheight2 > fs_floorheight2)
|
if (bs_floorheight1 > fs_floorheight1 || bs_floorheight2 > fs_floorheight2)
|
||||||
{
|
{
|
||||||
FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom));
|
FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom));
|
||||||
if (!tex || tex->UseType == ETextureType::Null) return false;
|
if (!tex || !tex->isValid()) return false;
|
||||||
}
|
}
|
||||||
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
||||||
frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false;
|
frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false;
|
||||||
|
|
|
@ -70,7 +70,7 @@ bool hw_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte
|
||||||
|
|
||||||
float xscale1 = secplane->Scale.X;
|
float xscale1 = secplane->Scale.X;
|
||||||
float yscale1 = secplane->Scale.Y;
|
float yscale1 = secplane->Scale.Y;
|
||||||
if (gltexture->tex->bHasCanvas)
|
if (gltexture->hasCanvas())
|
||||||
{
|
{
|
||||||
yscale1 = 0 - yscale1;
|
yscale1 = 0 - yscale1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -351,7 +351,7 @@ bool HWDrawInfo::DoOneSectorUpper(subsector_t * subsec, float Planez, area_t in_
|
||||||
{
|
{
|
||||||
// If there's a texture abort
|
// If there's a texture abort
|
||||||
FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::top)];
|
FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::top)];
|
||||||
if (!tex || tex->UseType == ETextureType::Null) continue;
|
if (!tex || !tex->isValid()) continue;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ bool HWDrawInfo::DoOneSectorLower(subsector_t * subsec, float Planez, area_t in_
|
||||||
{
|
{
|
||||||
// If there's a texture abort
|
// If there's a texture abort
|
||||||
FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::bottom)];
|
FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::bottom)];
|
||||||
if (!tex || tex->UseType == ETextureType::Null) continue;
|
if (!tex || !tex->isValid()) continue;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor)
|
||||||
|
|
||||||
FTextureID texno = s->GetTexture(pos);
|
FTextureID texno = s->GetTexture(pos);
|
||||||
texture[0] = FMaterial::ValidateTexture(texno, false, true);
|
texture[0] = FMaterial::ValidateTexture(texno, false, true);
|
||||||
if (!texture[0] || texture[0]->tex->UseType == ETextureType::Null) goto normalsky;
|
if (!texture[0] || !texture[0]->tex->isValid()) goto normalsky;
|
||||||
skytexno1 = texno;
|
skytexno1 = texno;
|
||||||
x_offset[0] = s->GetTextureXOffset(pos) * (360.f/65536.f);
|
x_offset[0] = s->GetTextureXOffset(pos) * (360.f/65536.f);
|
||||||
y_offset = s->GetTextureYOffset(pos);
|
y_offset = s->GetTextureYOffset(pos);
|
||||||
|
@ -244,7 +244,7 @@ void GLWall::SkyTop(HWDrawInfo *di, seg_t * seg,sector_t * fs,sector_t * bs,vert
|
||||||
if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+1.)
|
if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+1.)
|
||||||
{
|
{
|
||||||
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom));
|
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom));
|
||||||
if (!tex || tex->UseType==ETextureType::Null) return;
|
if (!tex || !tex->isValid()) return;
|
||||||
|
|
||||||
// very, very, very ugly special case (See Icarus MAP14)
|
// very, very, very ugly special case (See Icarus MAP14)
|
||||||
// It is VERY important that this is only done for a floor height difference of 1
|
// It is VERY important that this is only done for a floor height difference of 1
|
||||||
|
@ -327,8 +327,8 @@ void GLWall::SkyBottom(HWDrawInfo *di, seg_t * seg,sector_t * fs,sector_t * bs,v
|
||||||
if (bs->special == GLSector_NoSkyDraw) return;
|
if (bs->special == GLSector_NoSkyDraw) return;
|
||||||
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom));
|
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom));
|
||||||
|
|
||||||
// For lower skies the normal logic only applies to walls with no lower texture!
|
// For lower skies the normal logic only applies to walls with no lower texture.
|
||||||
if (tex->UseType==ETextureType::Null)
|
if (!tex->isValid())
|
||||||
{
|
{
|
||||||
if (bs->GetTexture(sector_t::floor)==skyflatnum)
|
if (bs->GetTexture(sector_t::floor)==skyflatnum)
|
||||||
{
|
{
|
||||||
|
@ -346,7 +346,7 @@ void GLWall::SkyBottom(HWDrawInfo *di, seg_t * seg,sector_t * fs,sector_t * bs,v
|
||||||
}
|
}
|
||||||
zbottom[0]=zbottom[1]=-32768.0f;
|
zbottom[0]=zbottom[1]=-32768.0f;
|
||||||
|
|
||||||
if ((tex && tex->UseType!=ETextureType::Null) || bs->GetTexture(sector_t::floor)!=skyflatnum)
|
if ((tex && !tex->isValid()) || bs->GetTexture(sector_t::floor)!=skyflatnum)
|
||||||
{
|
{
|
||||||
ztop[0]=zfloor[0];
|
ztop[0]=zfloor[0];
|
||||||
ztop[1]=zfloor[1];
|
ztop[1]=zfloor[1];
|
||||||
|
|
|
@ -293,7 +293,7 @@ void FSkyVertexBuffer::SetupMatrices(FMaterial *tex, float x_offset, float y_off
|
||||||
float yscale = 1.f;
|
float yscale = 1.f;
|
||||||
if (texh <= 128 && (level.flags & LEVEL_FORCETILEDSKY))
|
if (texh <= 128 && (level.flags & LEVEL_FORCETILEDSKY))
|
||||||
{
|
{
|
||||||
modelMatrix.translate(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f);
|
modelMatrix.translate(0.f, (-40 + tex->tex->GetSkyOffset() + skyoffset)*skyoffsetfactor, 0.f);
|
||||||
modelMatrix.scale(1.f, 1.2f * 1.17f, 1.f);
|
modelMatrix.scale(1.f, 1.2f * 1.17f, 1.f);
|
||||||
yscale = 240.f / texh;
|
yscale = 240.f / texh;
|
||||||
}
|
}
|
||||||
|
@ -311,12 +311,12 @@ void FSkyVertexBuffer::SetupMatrices(FMaterial *tex, float x_offset, float y_off
|
||||||
}
|
}
|
||||||
else if (texh <= 240)
|
else if (texh <= 240)
|
||||||
{
|
{
|
||||||
modelMatrix.translate(0.f, (200 - texh + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f);
|
modelMatrix.translate(0.f, (200 - texh + tex->tex->GetSkyOffset() + skyoffset)*skyoffsetfactor, 0.f);
|
||||||
modelMatrix.scale(1.f, 1.f + ((texh - 200.f) / 200.f) * 1.17f, 1.f);
|
modelMatrix.scale(1.f, 1.f + ((texh - 200.f) / 200.f) * 1.17f, 1.f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
modelMatrix.translate(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f);
|
modelMatrix.translate(0.f, (-40 + tex->tex->GetSkyOffset() + skyoffset)*skyoffsetfactor, 0.f);
|
||||||
modelMatrix.scale(1.f, 1.2f * 1.17f, 1.f);
|
modelMatrix.scale(1.f, 1.2f * 1.17f, 1.f);
|
||||||
yscale = 240.f / texh;
|
yscale = 240.f / texh;
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
||||||
di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1));
|
di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1));
|
||||||
|
|
||||||
state.SetVertexBuffer(vertexBuffer);
|
state.SetVertexBuffer(vertexBuffer);
|
||||||
if (origin->texture[0] && origin->texture[0]->tex->bSkybox)
|
if (origin->texture[0] && origin->texture[0]->tex->isSkybox())
|
||||||
{
|
{
|
||||||
RenderBox(di, state, origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2);
|
RenderBox(di, state, origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -791,7 +791,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
||||||
// Animate picnum overrides.
|
// Animate picnum overrides.
|
||||||
auto tex = TexMan(thing->picnum);
|
auto tex = TexMan(thing->picnum);
|
||||||
if (tex == nullptr) return;
|
if (tex == nullptr) return;
|
||||||
patch = tex->id;
|
patch = tex->GetID();
|
||||||
mirror = false;
|
mirror = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -910,7 +910,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
||||||
// allow disabling of the fullbright flag by a brightmap definition
|
// allow disabling of the fullbright flag by a brightmap definition
|
||||||
// (e.g. to do the gun flashes of Doom's zombies correctly.
|
// (e.g. to do the gun flashes of Doom's zombies correctly.
|
||||||
fullbright = (thing->flags5 & MF5_BRIGHT) ||
|
fullbright = (thing->flags5 & MF5_BRIGHT) ||
|
||||||
((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->bDisableFullbright));
|
((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->isFullbrightDisabled()));
|
||||||
|
|
||||||
lightlevel = fullbright ? 255 :
|
lightlevel = fullbright ? 255 :
|
||||||
hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ?
|
hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ?
|
||||||
|
|
|
@ -1000,7 +1000,7 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto
|
||||||
if (gltexture != NULL)
|
if (gltexture != NULL)
|
||||||
{
|
{
|
||||||
bool normalize = false;
|
bool normalize = false;
|
||||||
if (gltexture->tex->bHasCanvas) normalize = true;
|
if (gltexture->tex->isHardwareCanvas()) normalize = true;
|
||||||
else if (flags & GLWF_CLAMPY)
|
else if (flags & GLWF_CLAMPY)
|
||||||
{
|
{
|
||||||
// for negative scales we can get negative coordinates here.
|
// for negative scales we can get negative coordinates here.
|
||||||
|
@ -1029,7 +1029,7 @@ void GLWall::CheckTexturePosition(FTexCoordInfo *tci)
|
||||||
{
|
{
|
||||||
float sub;
|
float sub;
|
||||||
|
|
||||||
if (gltexture->tex->bHasCanvas) return;
|
if (gltexture->tex->isHardwareCanvas()) return;
|
||||||
|
|
||||||
// clamp texture coordinates to a reasonable range.
|
// clamp texture coordinates to a reasonable range.
|
||||||
// Extremely large values can cause visual problems
|
// Extremely large values can cause visual problems
|
||||||
|
@ -1223,7 +1223,7 @@ void GLWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary,
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::top));
|
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::top));
|
||||||
if (!tex || tex->UseType==ETextureType::Null)
|
if (!tex || !tex->isValid())
|
||||||
{
|
{
|
||||||
if (front->GetTexture(sector_t::ceiling) == skyflatnum &&
|
if (front->GetTexture(sector_t::ceiling) == skyflatnum &&
|
||||||
back->GetTexture(sector_t::ceiling) == skyflatnum && !wrap)
|
back->GetTexture(sector_t::ceiling) == skyflatnum && !wrap)
|
||||||
|
@ -1259,7 +1259,7 @@ void GLWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary,
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
tex = TexMan(seg->sidedef->GetTexture(side_t::bottom));
|
tex = TexMan(seg->sidedef->GetTexture(side_t::bottom));
|
||||||
if (!tex || tex->UseType==ETextureType::Null)
|
if (!tex || !tex->isValid())
|
||||||
{
|
{
|
||||||
// texture is missing - use the lower plane
|
// texture is missing - use the lower plane
|
||||||
bottomleft = MIN(bfh1,ffh1);
|
bottomleft = MIN(bfh1,ffh1);
|
||||||
|
|
|
@ -132,7 +132,7 @@ static bool isBright(DPSprite *psp)
|
||||||
if (lump.isValid())
|
if (lump.isValid())
|
||||||
{
|
{
|
||||||
FTexture * tex = TexMan(lump);
|
FTexture * tex = TexMan(lump);
|
||||||
if (tex) disablefullbright = tex->bDisableFullbright;
|
if (tex) disablefullbright = tex->isFullbrightDisabled();
|
||||||
}
|
}
|
||||||
return psp->GetState()->GetFullbright() && !disablefullbright;
|
return psp->GetState()->GetFullbright() && !disablefullbright;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,12 +164,12 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
||||||
{
|
{
|
||||||
mShaderIndex = SHADER_Paletted;
|
mShaderIndex = SHADER_Paletted;
|
||||||
}
|
}
|
||||||
else if (tx->bWarped)
|
else if (tx->isWarped())
|
||||||
{
|
{
|
||||||
mShaderIndex = tx->bWarped; // This picks SHADER_Warp1 or SHADER_Warp2
|
mShaderIndex = tx->isWarped(); // This picks SHADER_Warp1 or SHADER_Warp2
|
||||||
tx->shaderspeed = static_cast<FWarpTexture*>(tx)->GetSpeed();
|
tx->shaderspeed = static_cast<FWarpTexture*>(tx)->GetSpeed();
|
||||||
}
|
}
|
||||||
else if (tx->bHasCanvas)
|
else if (tx->isHardwareCanvas())
|
||||||
{
|
{
|
||||||
if (tx->shaderindex >= FIRST_USER_SHADER)
|
if (tx->shaderindex >= FIRST_USER_SHADER)
|
||||||
{
|
{
|
||||||
|
@ -265,7 +265,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
||||||
mMaxBound = -1;
|
mMaxBound = -1;
|
||||||
mMaterials.Push(this);
|
mMaterials.Push(this);
|
||||||
tx->Material[expanded] = this;
|
tx->Material[expanded] = this;
|
||||||
if (tx->bHasCanvas) tx->bTranslucent = 0;
|
if (tx->isHardwareCanvas()) tx->bTranslucent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
@ -484,19 +484,19 @@ int FMaterial::GetAreas(FloatRect **pAreas) const
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand)
|
FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand, bool create)
|
||||||
{
|
{
|
||||||
again:
|
again:
|
||||||
if (tex && tex->UseType!=ETextureType::Null)
|
if (tex && tex->isValid())
|
||||||
{
|
{
|
||||||
if (tex->bNoExpand) expand = false;
|
if (tex->bNoExpand) expand = false;
|
||||||
|
|
||||||
FMaterial *gltex = tex->Material[expand];
|
FMaterial *gltex = tex->Material[expand];
|
||||||
if (gltex == NULL)
|
if (gltex == NULL && create)
|
||||||
{
|
{
|
||||||
if (expand)
|
if (expand)
|
||||||
{
|
{
|
||||||
if (tex->bWarped || tex->bHasCanvas || tex->shaderindex >= FIRST_USER_SHADER || (tex->shaderindex >= SHADER_Specular && tex->shaderindex <= SHADER_PBRBrightmap))
|
if (tex->isWarped() || tex->isHardwareCanvas() || tex->shaderindex >= FIRST_USER_SHADER || (tex->shaderindex >= SHADER_Specular && tex->shaderindex <= SHADER_PBRBrightmap))
|
||||||
{
|
{
|
||||||
tex->bNoExpand = true;
|
tex->bNoExpand = true;
|
||||||
goto again;
|
goto again;
|
||||||
|
@ -518,9 +518,9 @@ again:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMaterial * FMaterial::ValidateTexture(FTextureID no, bool expand, bool translate)
|
FMaterial * FMaterial::ValidateTexture(FTextureID no, bool expand, bool translate, bool create)
|
||||||
{
|
{
|
||||||
return ValidateTexture(translate? TexMan(no) : TexMan[no], expand);
|
return ValidateTexture(translate? TexMan(no) : TexMan[no], expand, create);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -554,41 +554,3 @@ void FMaterial::Clean(bool f)
|
||||||
mBaseLayer->Clean(f);
|
mBaseLayer->Clean(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// Prints some texture info
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
CCMD(textureinfo)
|
|
||||||
{
|
|
||||||
int cntt = 0;
|
|
||||||
for (int i = 0; i < TexMan.NumTextures(); i++)
|
|
||||||
{
|
|
||||||
FTexture *tex = TexMan.ByIndex(i);
|
|
||||||
if (tex->SystemTexture[0] || tex->SystemTexture[1] || tex->Material[0] || tex->Material[1])
|
|
||||||
{
|
|
||||||
int lump = tex->GetSourceLump();
|
|
||||||
Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name.GetChars(), i, lump, Wads.GetLumpFullName(lump));
|
|
||||||
if (tex->Material[0])
|
|
||||||
{
|
|
||||||
Printf(PRINT_LOG, "in use (normal)\n");
|
|
||||||
}
|
|
||||||
else if (tex->SystemTexture[0])
|
|
||||||
{
|
|
||||||
Printf(PRINT_LOG, "referenced (normal)\n");
|
|
||||||
}
|
|
||||||
if (tex->Material[1])
|
|
||||||
{
|
|
||||||
Printf(PRINT_LOG, "in use (expanded)\n");
|
|
||||||
}
|
|
||||||
else if (tex->SystemTexture[1])
|
|
||||||
{
|
|
||||||
Printf(PRINT_LOG, "referenced (normal)\n");
|
|
||||||
}
|
|
||||||
cntt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Printf(PRINT_LOG, "%d system textures\n", cntt);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,11 @@ public:
|
||||||
return mTextureLayers.Size() + 1;
|
return mTextureLayers.Size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool hasCanvas()
|
||||||
|
{
|
||||||
|
return tex->isHardwareCanvas();
|
||||||
|
}
|
||||||
|
|
||||||
IHardwareTexture *GetLayer(int i, FTexture **pLayer = nullptr)
|
IHardwareTexture *GetLayer(int i, FTexture **pLayer = nullptr)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
|
@ -165,8 +170,8 @@ public:
|
||||||
|
|
||||||
static void DeleteAll();
|
static void DeleteAll();
|
||||||
static void FlushAll();
|
static void FlushAll();
|
||||||
static FMaterial *ValidateTexture(FTexture * tex, bool expand);
|
static FMaterial *ValidateTexture(FTexture * tex, bool expand, bool create = true);
|
||||||
static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans);
|
static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans, bool create = true);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -48,11 +48,6 @@ static void PrecacheTexture(FTexture *tex, int cache)
|
||||||
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
|
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
|
||||||
if (gltex) gltex->Precache();
|
if (gltex) gltex->Precache();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// make sure that software pixel buffers do not stick around for unneeded textures.
|
|
||||||
tex->Unload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -91,14 +86,14 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
||||||
if (texhitlist[i] & (FTextureManager::HIT_Sky | FTextureManager::HIT_Wall))
|
if (texhitlist[i] & (FTextureManager::HIT_Sky | FTextureManager::HIT_Wall))
|
||||||
{
|
{
|
||||||
FTexture *tex = TexMan.ByIndex(i);
|
FTexture *tex = TexMan.ByIndex(i);
|
||||||
if (tex->bSkybox)
|
if (tex->isSkybox())
|
||||||
{
|
{
|
||||||
FSkyBox *sb = static_cast<FSkyBox*>(tex);
|
FSkyBox *sb = static_cast<FSkyBox*>(tex);
|
||||||
for (int i = 0; i<6; i++)
|
for (int i = 0; i<6; i++)
|
||||||
{
|
{
|
||||||
if (sb->faces[i])
|
if (sb->faces[i])
|
||||||
{
|
{
|
||||||
int index = sb->faces[i]->id.GetIndex();
|
int index = sb->faces[i]->GetID().GetIndex();
|
||||||
texhitlist[index] |= FTextureManager::HIT_Flat;
|
texhitlist[index] |= FTextureManager::HIT_Flat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,11 +176,13 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
||||||
{
|
{
|
||||||
if (!texhitlist[i])
|
if (!texhitlist[i])
|
||||||
{
|
{
|
||||||
if (tex->Material[0]) tex->Material[0]->Clean(true);
|
auto mat = FMaterial::ValidateTexture(tex, false, false);
|
||||||
|
if (mat) mat->Clean(true);
|
||||||
}
|
}
|
||||||
if (spritehitlist[i] == nullptr || (*spritehitlist[i]).CountUsed() == 0)
|
if (spritehitlist[i] == nullptr || (*spritehitlist[i]).CountUsed() == 0)
|
||||||
{
|
{
|
||||||
if (tex->Material[1]) tex->Material[1]->Clean(true);
|
auto mat = FMaterial::ValidateTexture(tex, true, false);
|
||||||
|
if (mat) mat->Clean(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
|
||||||
state.EnableTexture(true);
|
state.EnableTexture(true);
|
||||||
|
|
||||||
// Canvas textures are stored upside down
|
// Canvas textures are stored upside down
|
||||||
if (cmd.mTexture->bHasCanvas)
|
if (cmd.mTexture->isHardwareCanvas())
|
||||||
{
|
{
|
||||||
state.mTextureMatrix.loadIdentity();
|
state.mTextureMatrix.loadIdentity();
|
||||||
state.mTextureMatrix.scale(1.f, -1.f, 1.f);
|
state.mTextureMatrix.scale(1.f, -1.f, 1.f);
|
||||||
|
|
|
@ -573,8 +573,8 @@ void DIntermissionScreenCast::Drawer ()
|
||||||
screen->DrawTexture (pic, 160, 170,
|
screen->DrawTexture (pic, 160, 170,
|
||||||
DTA_320x200, true,
|
DTA_320x200, true,
|
||||||
DTA_FlipX, sprframe->Flip & 1,
|
DTA_FlipX, sprframe->Flip & 1,
|
||||||
DTA_DestHeightF, pic->GetScaledHeightDouble() * castscale.Y,
|
DTA_DestHeightF, pic->GetDisplayHeightDouble() * castscale.Y,
|
||||||
DTA_DestWidthF, pic->GetScaledWidthDouble() * castscale.X,
|
DTA_DestWidthF, pic->GetDisplayWidthDouble() * castscale.X,
|
||||||
DTA_RenderStyle, mDefaults->RenderStyle,
|
DTA_RenderStyle, mDefaults->RenderStyle,
|
||||||
DTA_Alpha, mDefaults->Alpha,
|
DTA_Alpha, mDefaults->Alpha,
|
||||||
DTA_TranslationIndex, casttranslation,
|
DTA_TranslationIndex, casttranslation,
|
||||||
|
@ -616,8 +616,8 @@ void DIntermissionScreenScroller::Drawer ()
|
||||||
if (mTicker >= mScrollDelay && mTicker < mScrollDelay + mScrollTime && tex != NULL && tex2 != NULL)
|
if (mTicker >= mScrollDelay && mTicker < mScrollDelay + mScrollTime && tex != NULL && tex2 != NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
int fwidth = tex->GetScaledWidth();
|
int fwidth = tex->GetDisplayWidth();
|
||||||
int fheight = tex->GetScaledHeight();
|
int fheight = tex->GetDisplayHeight();
|
||||||
|
|
||||||
double xpos1 = 0, ypos1 = 0, xpos2 = 0, ypos2 = 0;
|
double xpos1 = 0, ypos1 = 0, xpos2 = 0, ypos2 = 0;
|
||||||
|
|
||||||
|
|
|
@ -502,7 +502,7 @@ unsigned FSavegameManager::ExtractSaveData(int index)
|
||||||
{
|
{
|
||||||
SavePic = PNGTexture_CreateFromFile(png, node->Filename);
|
SavePic = PNGTexture_CreateFromFile(png, node->Filename);
|
||||||
delete png;
|
delete png;
|
||||||
if (SavePic->GetWidth() == 1 && SavePic->GetHeight() == 1)
|
if (SavePic->GetDisplayWidth() == 1 && SavePic->GetDisplayHeight() == 1)
|
||||||
{
|
{
|
||||||
delete SavePic;
|
delete SavePic;
|
||||||
SavePic = nullptr;
|
SavePic = nullptr;
|
||||||
|
|
|
@ -6690,7 +6690,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
||||||
auto a = SingleActorFromTID(args[0], activator);
|
auto a = SingleActorFromTID(args[0], activator);
|
||||||
if (a != nullptr)
|
if (a != nullptr)
|
||||||
{
|
{
|
||||||
return GlobalACSStrings.AddString(TexMan[a->floorpic]->Name);
|
return GlobalACSStrings.AddString(TexMan[a->floorpic]->GetName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -294,7 +294,7 @@ void DDoor::DoorSound(bool raise, DSeqNode *curseq) const
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FTexture *tex = TexMan[line->sidedef[0]->GetTexture(side_t::top)];
|
FTexture *tex = TexMan[line->sidedef[0]->GetTexture(side_t::top)];
|
||||||
texname = tex ? tex->Name.GetChars() : NULL;
|
texname = tex ? tex->GetName().GetChars() : NULL;
|
||||||
if (texname != NULL && texname[0] == 'D' && texname[1] == 'O' && texname[2] == 'R')
|
if (texname != NULL && texname[0] == 'D' && texname[1] == 'O' && texname[2] == 'R')
|
||||||
{
|
{
|
||||||
switch (texname[3])
|
switch (texname[3])
|
||||||
|
@ -715,9 +715,8 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay,
|
||||||
|
|
||||||
picnum = tex1[side_t::top].texture;
|
picnum = tex1[side_t::top].texture;
|
||||||
|
|
||||||
// don't forget texture scaling here!
|
|
||||||
FTexture *tex = TexMan[picnum];
|
FTexture *tex = TexMan[picnum];
|
||||||
topdist = tex ? tex->GetScaledHeight() : 64;
|
topdist = tex ? tex->GetDisplayHeight() : 64;
|
||||||
|
|
||||||
topdist = m_Sector->ceilingplane.fD() - topdist * m_Sector->ceilingplane.fC();
|
topdist = m_Sector->ceilingplane.fD() - topdist * m_Sector->ceilingplane.fC();
|
||||||
|
|
||||||
|
|
|
@ -480,7 +480,7 @@ static inline void CheckShortestTex (FTextureID texnum, double &minsize)
|
||||||
FTexture *tex = TexMan[texnum];
|
FTexture *tex = TexMan[texnum];
|
||||||
if (tex != NULL)
|
if (tex != NULL)
|
||||||
{
|
{
|
||||||
double h = tex->GetScaledHeight();
|
double h = tex->GetDisplayHeight();
|
||||||
if (h < minsize)
|
if (h < minsize)
|
||||||
{
|
{
|
||||||
minsize = h;
|
minsize = h;
|
||||||
|
@ -501,7 +501,7 @@ double FindShortestTextureAround (sector_t *sec)
|
||||||
CheckShortestTex (check->sidedef[1]->GetTexture(side_t::bottom), minsize);
|
CheckShortestTex (check->sidedef[1]->GetTexture(side_t::bottom), minsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return minsize < FLT_MAX ? minsize : TexMan[0]->GetHeight();
|
return minsize < FLT_MAX ? minsize : TexMan[0]->GetDisplayHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -526,7 +526,7 @@ double FindShortestUpperAround (sector_t *sec)
|
||||||
CheckShortestTex (check->sidedef[1]->GetTexture(side_t::top), minsize);
|
CheckShortestTex (check->sidedef[1]->GetTexture(side_t::top), minsize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return minsize < FLT_MAX ? minsize : TexMan[0]->GetHeight();
|
return minsize < FLT_MAX ? minsize : TexMan[0]->GetDisplayHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1147,11 +1147,11 @@ double GetFriction(const sector_t *self, int plane, double *pMoveFac)
|
||||||
FTexture *tex = TexMan[GetTexture(sector_t::floor)];
|
FTexture *tex = TexMan[GetTexture(sector_t::floor)];
|
||||||
if (tex != NULL && tex->isGlowing())
|
if (tex != NULL && tex->isGlowing())
|
||||||
{
|
{
|
||||||
if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::floor));
|
if (!tex->isAutoGlowing()) tex = TexMan(GetTexture(sector_t::floor));
|
||||||
if (tex->isGlowing()) // recheck the current animation frame.
|
if (tex->isGlowing()) // recheck the current animation frame.
|
||||||
{
|
{
|
||||||
tex->GetGlowColor(bottomglowcolor);
|
tex->GetGlowColor(bottomglowcolor);
|
||||||
bottomglowcolor[3] = (float)tex->GlowHeight;
|
bottomglowcolor[3] = (float)tex->GetGlowHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1192,12 +1192,12 @@ double GetFriction(const sector_t *self, int plane, double *pMoveFac)
|
||||||
FTexture *tex = TexMan[GetTexture(sector_t::ceiling)];
|
FTexture *tex = TexMan[GetTexture(sector_t::ceiling)];
|
||||||
if (tex != NULL && tex->isGlowing())
|
if (tex != NULL && tex->isGlowing())
|
||||||
{
|
{
|
||||||
if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::ceiling));
|
if (!tex->isAutoGlowing()) tex = TexMan(GetTexture(sector_t::ceiling));
|
||||||
if (tex->isGlowing()) // recheck the current animation frame.
|
if (tex->isGlowing()) // recheck the current animation frame.
|
||||||
{
|
{
|
||||||
ret = true;
|
ret = true;
|
||||||
tex->GetGlowColor(topglowcolor);
|
tex->GetGlowColor(topglowcolor);
|
||||||
topglowcolor[3] = (float)tex->GlowHeight;
|
topglowcolor[3] = (float)tex->GetGlowHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1216,12 +1216,12 @@ double GetFriction(const sector_t *self, int plane, double *pMoveFac)
|
||||||
FTexture *tex = TexMan[GetTexture(sector_t::floor)];
|
FTexture *tex = TexMan[GetTexture(sector_t::floor)];
|
||||||
if (tex != NULL && tex->isGlowing())
|
if (tex != NULL && tex->isGlowing())
|
||||||
{
|
{
|
||||||
if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::floor));
|
if (!tex->isAutoGlowing()) tex = TexMan(GetTexture(sector_t::floor));
|
||||||
if (tex->isGlowing()) // recheck the current animation frame.
|
if (tex->isGlowing()) // recheck the current animation frame.
|
||||||
{
|
{
|
||||||
ret = true;
|
ret = true;
|
||||||
tex->GetGlowColor(bottomglowcolor);
|
tex->GetGlowColor(bottomglowcolor);
|
||||||
bottomglowcolor[3] = (float)tex->GlowHeight;
|
bottomglowcolor[3] = (float)tex->GetGlowHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ void PolyDrawArgs::SetTexture(const uint8_t *texels, int width, int height)
|
||||||
mTranslation = nullptr;
|
mTranslation = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDrawArgs::SetTexture(FTexture *texture, FRenderStyle style)
|
void PolyDrawArgs::SetTexture(FSoftwareTexture *texture, FRenderStyle style)
|
||||||
{
|
{
|
||||||
mTexture = texture;
|
mTexture = texture;
|
||||||
mTextureWidth = texture->GetWidth();
|
mTextureWidth = texture->GetWidth();
|
||||||
|
@ -59,7 +59,7 @@ void PolyDrawArgs::SetTexture(FTexture *texture, FRenderStyle style)
|
||||||
mTranslation = nullptr;
|
mTranslation = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDrawArgs::SetTexture(FTexture *texture, uint32_t translationID, FRenderStyle style)
|
void PolyDrawArgs::SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style)
|
||||||
{
|
{
|
||||||
// Alphatexture overrides translations.
|
// Alphatexture overrides translations.
|
||||||
if (translationID != 0xffffffff && translationID != 0 && !(style.Flags & STYLEF_RedIsAlpha))
|
if (translationID != 0xffffffff && translationID != 0 && !(style.Flags & STYLEF_RedIsAlpha))
|
||||||
|
@ -140,7 +140,7 @@ void PolyDrawArgs::SetColor(uint32_t bgra, uint8_t palindex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *tex, bool fullbright)
|
void PolyDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *tex, bool fullbright)
|
||||||
{
|
{
|
||||||
SetTexture(tex, translationID, renderstyle);
|
SetTexture(tex, translationID, renderstyle);
|
||||||
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
|
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
|
||||||
|
@ -203,7 +203,7 @@ void PolyDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint3
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void RectDrawArgs::SetTexture(FTexture *texture, FRenderStyle style)
|
void RectDrawArgs::SetTexture(FSoftwareTexture *texture, FRenderStyle style)
|
||||||
{
|
{
|
||||||
mTexture = texture;
|
mTexture = texture;
|
||||||
mTextureWidth = texture->GetWidth();
|
mTextureWidth = texture->GetWidth();
|
||||||
|
@ -215,7 +215,7 @@ void RectDrawArgs::SetTexture(FTexture *texture, FRenderStyle style)
|
||||||
mTranslation = nullptr;
|
mTranslation = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectDrawArgs::SetTexture(FTexture *texture, uint32_t translationID, FRenderStyle style)
|
void RectDrawArgs::SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style)
|
||||||
{
|
{
|
||||||
// Alphatexture overrides translations.
|
// Alphatexture overrides translations.
|
||||||
if (translationID != 0xffffffff && translationID != 0 && !(style.Flags & STYLEF_RedIsAlpha))
|
if (translationID != 0xffffffff && translationID != 0 && !(style.Flags & STYLEF_RedIsAlpha))
|
||||||
|
@ -291,7 +291,7 @@ void RectDrawArgs::Draw(PolyRenderThread *thread, double x0, double x1, double y
|
||||||
thread->DrawQueue->Push<DrawRectCommand>(*this);
|
thread->DrawQueue->Push<DrawRectCommand>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RectDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *tex, bool fullbright)
|
void RectDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *tex, bool fullbright)
|
||||||
{
|
{
|
||||||
SetTexture(tex, translationID, renderstyle);
|
SetTexture(tex, translationID, renderstyle);
|
||||||
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
|
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#include "screen_triangle.h"
|
#include "screen_triangle.h"
|
||||||
|
|
||||||
class PolyRenderThread;
|
class PolyRenderThread;
|
||||||
class FTexture;
|
class FSoftwareTexture;
|
||||||
class Mat4f;
|
class Mat4f;
|
||||||
|
|
||||||
enum class PolyDrawMode
|
enum class PolyDrawMode
|
||||||
|
@ -67,8 +67,8 @@ class PolyDrawArgs
|
||||||
public:
|
public:
|
||||||
void SetClipPlane(int index, const PolyClipPlane &plane) { mClipPlane[index] = plane; }
|
void SetClipPlane(int index, const PolyClipPlane &plane) { mClipPlane[index] = plane; }
|
||||||
void SetTexture(const uint8_t *texels, int width, int height);
|
void SetTexture(const uint8_t *texels, int width, int height);
|
||||||
void SetTexture(FTexture *texture, FRenderStyle style);
|
void SetTexture(FSoftwareTexture *texture, FRenderStyle style);
|
||||||
void SetTexture(FTexture *texture, uint32_t translationID, FRenderStyle style);
|
void SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style);
|
||||||
void SetLight(FSWColormap *basecolormap, uint32_t lightlevel, double globVis, bool fixed);
|
void SetLight(FSWColormap *basecolormap, uint32_t lightlevel, double globVis, bool fixed);
|
||||||
void SetDepthTest(bool enable) { mDepthTest = enable; }
|
void SetDepthTest(bool enable) { mDepthTest = enable; }
|
||||||
void SetStencilTestValue(uint8_t stencilTestValue) { mStencilTestValue = stencilTestValue; }
|
void SetStencilTestValue(uint8_t stencilTestValue) { mStencilTestValue = stencilTestValue; }
|
||||||
|
@ -76,7 +76,7 @@ public:
|
||||||
void SetWriteStencil(bool enable, uint8_t stencilWriteValue = 0) { mWriteStencil = enable; mStencilWriteValue = stencilWriteValue; }
|
void SetWriteStencil(bool enable, uint8_t stencilWriteValue = 0) { mWriteStencil = enable; mStencilWriteValue = stencilWriteValue; }
|
||||||
void SetWriteDepth(bool enable) { mWriteDepth = enable; }
|
void SetWriteDepth(bool enable) { mWriteDepth = enable; }
|
||||||
void SetStyle(TriBlendMode blendmode, double alpha = 1.0) { mBlendMode = blendmode; mAlpha = (uint32_t)(alpha * 256.0 + 0.5); }
|
void SetStyle(TriBlendMode blendmode, double alpha = 1.0) { mBlendMode = blendmode; mAlpha = (uint32_t)(alpha * 256.0 + 0.5); }
|
||||||
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *texture, bool fullbright);
|
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *texture, bool fullbright);
|
||||||
void SetColor(uint32_t bgra, uint8_t palindex);
|
void SetColor(uint32_t bgra, uint8_t palindex);
|
||||||
void SetLights(PolyLight *lights, int numLights) { mLights = lights; mNumLights = numLights; }
|
void SetLights(PolyLight *lights, int numLights) { mLights = lights; mNumLights = numLights; }
|
||||||
void SetDynLightColor(uint32_t color) { mDynLightColor = color; }
|
void SetDynLightColor(uint32_t color) { mDynLightColor = color; }
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
|
|
||||||
bool WriteColor() const { return mWriteColor; }
|
bool WriteColor() const { return mWriteColor; }
|
||||||
|
|
||||||
FTexture *Texture() const { return mTexture; }
|
FSoftwareTexture *Texture() const { return mTexture; }
|
||||||
const uint8_t *TexturePixels() const { return mTexturePixels; }
|
const uint8_t *TexturePixels() const { return mTexturePixels; }
|
||||||
int TextureWidth() const { return mTextureWidth; }
|
int TextureWidth() const { return mTextureWidth; }
|
||||||
int TextureHeight() const { return mTextureHeight; }
|
int TextureHeight() const { return mTextureHeight; }
|
||||||
|
@ -131,7 +131,7 @@ private:
|
||||||
bool mWriteStencil = true;
|
bool mWriteStencil = true;
|
||||||
bool mWriteColor = true;
|
bool mWriteColor = true;
|
||||||
bool mWriteDepth = true;
|
bool mWriteDepth = true;
|
||||||
FTexture *mTexture = nullptr;
|
FSoftwareTexture *mTexture = nullptr;
|
||||||
const uint8_t *mTexturePixels = nullptr;
|
const uint8_t *mTexturePixels = nullptr;
|
||||||
int mTextureWidth = 0;
|
int mTextureWidth = 0;
|
||||||
int mTextureHeight = 0;
|
int mTextureHeight = 0;
|
||||||
|
@ -166,15 +166,15 @@ private:
|
||||||
class RectDrawArgs
|
class RectDrawArgs
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void SetTexture(FTexture *texture, FRenderStyle style);
|
void SetTexture(FSoftwareTexture *texture, FRenderStyle style);
|
||||||
void SetTexture(FTexture *texture, uint32_t translationID, FRenderStyle style);
|
void SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style);
|
||||||
void SetLight(FSWColormap *basecolormap, uint32_t lightlevel);
|
void SetLight(FSWColormap *basecolormap, uint32_t lightlevel);
|
||||||
void SetStyle(TriBlendMode blendmode, double alpha = 1.0) { mBlendMode = blendmode; mAlpha = (uint32_t)(alpha * 256.0 + 0.5); }
|
void SetStyle(TriBlendMode blendmode, double alpha = 1.0) { mBlendMode = blendmode; mAlpha = (uint32_t)(alpha * 256.0 + 0.5); }
|
||||||
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *texture, bool fullbright);
|
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *texture, bool fullbright);
|
||||||
void SetColor(uint32_t bgra, uint8_t palindex);
|
void SetColor(uint32_t bgra, uint8_t palindex);
|
||||||
void Draw(PolyRenderThread *thread, double x0, double x1, double y0, double y1, double u0, double u1, double v0, double v1);
|
void Draw(PolyRenderThread *thread, double x0, double x1, double y0, double y1, double u0, double u1, double v0, double v1);
|
||||||
|
|
||||||
FTexture *Texture() const { return mTexture; }
|
FSoftwareTexture *Texture() const { return mTexture; }
|
||||||
const uint8_t *TexturePixels() const { return mTexturePixels; }
|
const uint8_t *TexturePixels() const { return mTexturePixels; }
|
||||||
int TextureWidth() const { return mTextureWidth; }
|
int TextureWidth() const { return mTextureWidth; }
|
||||||
int TextureHeight() const { return mTextureHeight; }
|
int TextureHeight() const { return mTextureHeight; }
|
||||||
|
@ -207,7 +207,7 @@ public:
|
||||||
float V1() const { return mV1; }
|
float V1() const { return mV1; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FTexture *mTexture = nullptr;
|
FSoftwareTexture *mTexture = nullptr;
|
||||||
const uint8_t *mTexturePixels = nullptr;
|
const uint8_t *mTexturePixels = nullptr;
|
||||||
int mTextureWidth = 0;
|
int mTextureWidth = 0;
|
||||||
int mTextureHeight = 0;
|
int mTextureHeight = 0;
|
||||||
|
|
|
@ -74,7 +74,7 @@ void PolyRenderThread::FlushDrawQueue()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style)
|
void PolyRenderThread::PrepareTexture(FSoftwareTexture *texture, FRenderStyle style)
|
||||||
{
|
{
|
||||||
if (texture == nullptr)
|
if (texture == nullptr)
|
||||||
return;
|
return;
|
||||||
|
@ -92,7 +92,7 @@ void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style)
|
||||||
std::unique_lock<std::mutex> lock(loadmutex);
|
std::unique_lock<std::mutex> lock(loadmutex);
|
||||||
|
|
||||||
texture->GetPixels(style);
|
texture->GetPixels(style);
|
||||||
const FTexture::Span *spans;
|
const FSoftwareTextureSpan *spans;
|
||||||
texture->GetColumn(style, 0, &spans);
|
texture->GetColumn(style, 0, &spans);
|
||||||
if (PolyRenderer::Instance()->RenderTarget->IsBgra())
|
if (PolyRenderer::Instance()->RenderTarget->IsBgra())
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
TArray<ADynamicLight*> AddedLightsArray;
|
TArray<ADynamicLight*> AddedLightsArray;
|
||||||
|
|
||||||
// Make sure texture can accessed safely
|
// Make sure texture can accessed safely
|
||||||
void PrepareTexture(FTexture *texture, FRenderStyle style);
|
void PrepareTexture(FSoftwareTexture *texture, FRenderStyle style);
|
||||||
|
|
||||||
// Setup poly object in a threadsafe manner
|
// Setup poly object in a threadsafe manner
|
||||||
void PreparePolyObject(subsector_t *sub);
|
void PreparePolyObject(subsector_t *sub);
|
||||||
|
|
|
@ -49,10 +49,12 @@ void RenderPolyDecal::Render(PolyRenderThread *thread, DBaseDecal *decal, const
|
||||||
if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid())
|
if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FTexture *tex = TexMan(decal->PicNum, true);
|
FTexture *ttex = TexMan(decal->PicNum, true);
|
||||||
if (tex == nullptr || tex->UseType == ETextureType::Null)
|
if (ttex == nullptr || !ttex->isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
FSoftwareTexture *tex = ttex->GetSoftwareTexture();
|
||||||
|
|
||||||
sector_t *front, *back;
|
sector_t *front, *back;
|
||||||
GetDecalSectors(decal, line, &front, &back);
|
GetDecalSectors(decal, line, &front, &back);
|
||||||
|
|
||||||
|
@ -73,16 +75,16 @@ void RenderPolyDecal::Render(PolyRenderThread *thread, DBaseDecal *decal, const
|
||||||
|
|
||||||
bool flipTextureX = (decal->RenderFlags & RF_XFLIP) == RF_XFLIP;
|
bool flipTextureX = (decal->RenderFlags & RF_XFLIP) == RF_XFLIP;
|
||||||
double u_left = flipTextureX ? 1.0 : 0.0;
|
double u_left = flipTextureX ? 1.0 : 0.0;
|
||||||
double u_right = flipTextureX ? 1.0 - tex->Scale.X : tex->Scale.X;
|
double u_right = flipTextureX ? 1.0 - tex->GetScale().X : tex->GetScale().X;
|
||||||
double u_unit = (u_right - u_left) / (edge_left + edge_right);
|
double u_unit = (u_right - u_left) / (edge_left + edge_right);
|
||||||
|
|
||||||
double zpos = GetDecalZ(decal, line, front, back);
|
double zpos = GetDecalZ(decal, line, front, back);
|
||||||
double spriteHeight = decal->ScaleY / tex->Scale.Y * tex->GetHeight();
|
double spriteHeight = decal->ScaleY / tex->GetScale().Y * tex->GetHeight();
|
||||||
double ztop = zpos + spriteHeight - spriteHeight * 0.5;
|
double ztop = zpos + spriteHeight - spriteHeight * 0.5;
|
||||||
double zbottom = zpos - spriteHeight * 0.5;
|
double zbottom = zpos - spriteHeight * 0.5;
|
||||||
|
|
||||||
double v_top = 0.0;
|
double v_top = 0.0;
|
||||||
double v_bottom = tex->Scale.Y;
|
double v_bottom = tex->GetScale().Y;
|
||||||
double v_unit = (v_bottom - v_top) / (zbottom - ztop);
|
double v_unit = (v_bottom - v_top) / (zbottom - ztop);
|
||||||
|
|
||||||
// Clip decal to wall part
|
// Clip decal to wall part
|
||||||
|
|
|
@ -67,7 +67,7 @@ static bool isBright(DPSprite *psp)
|
||||||
if (lump.isValid())
|
if (lump.isValid())
|
||||||
{
|
{
|
||||||
FTexture * tex = TexMan(lump);
|
FTexture * tex = TexMan(lump);
|
||||||
if (tex) disablefullbright = tex->bDisableFullbright;
|
if (tex) disablefullbright = tex->isFullbrightDisabled();
|
||||||
}
|
}
|
||||||
return psp->GetState()->GetFullbright() && !disablefullbright;
|
return psp->GetState()->GetFullbright() && !disablefullbright;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ void PolyModelRenderer::SetInterpolation(double interpolation)
|
||||||
|
|
||||||
void PolyModelRenderer::SetMaterial(FTexture *skin, bool clampNoFilter, int translation)
|
void PolyModelRenderer::SetMaterial(FTexture *skin, bool clampNoFilter, int translation)
|
||||||
{
|
{
|
||||||
SkinTexture = skin;
|
SkinTexture = skin? skin->GetSoftwareTexture() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyModelRenderer::SetTransform()
|
void PolyModelRenderer::SetTransform()
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
uint32_t Translation;
|
uint32_t Translation;
|
||||||
|
|
||||||
Mat4f ObjectToWorld;
|
Mat4f ObjectToWorld;
|
||||||
FTexture *SkinTexture = nullptr;
|
FSoftwareTexture *SkinTexture = nullptr;
|
||||||
unsigned int *IndexBuffer = nullptr;
|
unsigned int *IndexBuffer = nullptr;
|
||||||
FModelVertex *VertexBuffer = nullptr;
|
FModelVertex *VertexBuffer = nullptr;
|
||||||
float InterpolationFactor = 0.0;
|
float InterpolationFactor = 0.0;
|
||||||
|
|
|
@ -67,10 +67,10 @@ void RenderPolyPlane::RenderNormal(PolyRenderThread *thread, const PolyTransferH
|
||||||
if (picnum != skyflatnum)
|
if (picnum != skyflatnum)
|
||||||
{
|
{
|
||||||
FTexture *tex = TexMan(picnum);
|
FTexture *tex = TexMan(picnum);
|
||||||
if (!tex || tex->UseType == ETextureType::Null)
|
if (!tex || !tex->isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PolyPlaneUVTransform transform = PolyPlaneUVTransform(ceiling ? fakeflat.FrontSector->planes[sector_t::ceiling].xform : fakeflat.FrontSector->planes[sector_t::floor].xform, tex);
|
PolyPlaneUVTransform transform = PolyPlaneUVTransform(ceiling ? fakeflat.FrontSector->planes[sector_t::ceiling].xform : fakeflat.FrontSector->planes[sector_t::floor].xform, tex->GetSoftwareTexture());
|
||||||
TriVertex *vertices = CreatePlaneVertices(thread, fakeflat.Subsector, transform, ceiling ? fakeflat.FrontSector->ceilingplane : fakeflat.FrontSector->floorplane);
|
TriVertex *vertices = CreatePlaneVertices(thread, fakeflat.Subsector, transform, ceiling ? fakeflat.FrontSector->ceilingplane : fakeflat.FrontSector->floorplane);
|
||||||
|
|
||||||
PolyDrawArgs args;
|
PolyDrawArgs args;
|
||||||
|
@ -78,7 +78,7 @@ void RenderPolyPlane::RenderNormal(PolyRenderThread *thread, const PolyTransferH
|
||||||
SetDynLights(thread, args, fakeflat.Subsector, ceiling);
|
SetDynLights(thread, args, fakeflat.Subsector, ceiling);
|
||||||
args.SetStencilTestValue(stencilValue);
|
args.SetStencilTestValue(stencilValue);
|
||||||
args.SetWriteStencil(true, stencilValue + 1);
|
args.SetWriteStencil(true, stencilValue + 1);
|
||||||
args.SetTexture(tex, DefaultRenderStyle());
|
args.SetTexture(tex->GetSoftwareTexture(), DefaultRenderStyle());
|
||||||
args.SetStyle(TriBlendMode::Opaque);
|
args.SetStyle(TriBlendMode::Opaque);
|
||||||
PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan);
|
PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan);
|
||||||
}
|
}
|
||||||
|
@ -389,12 +389,12 @@ TriVertex *RenderPolyPlane::CreateSkyPlaneVertices(PolyRenderThread *thread, sub
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
PolyPlaneUVTransform::PolyPlaneUVTransform(const FTransform &transform, FTexture *tex)
|
PolyPlaneUVTransform::PolyPlaneUVTransform(const FTransform &transform, FSoftwareTexture *tex)
|
||||||
{
|
{
|
||||||
if (tex)
|
if (tex)
|
||||||
{
|
{
|
||||||
xscale = (float)(transform.xScale * tex->Scale.X / tex->GetWidth());
|
xscale = (float)(transform.xScale * tex->GetScale().X / tex->GetWidth());
|
||||||
yscale = (float)(transform.yScale * tex->Scale.Y / tex->GetHeight());
|
yscale = (float)(transform.yScale * tex->GetScale().Y / tex->GetHeight());
|
||||||
|
|
||||||
double planeang = (transform.Angle + transform.baseAngle).Radians();
|
double planeang = (transform.Angle + transform.baseAngle).Radians();
|
||||||
cosine = (float)cos(planeang);
|
cosine = (float)cos(planeang);
|
||||||
|
@ -510,8 +510,8 @@ void Render3DFloorPlane::RenderPlanes(PolyRenderThread *thread, subsector_t *sub
|
||||||
void Render3DFloorPlane::Render(PolyRenderThread *thread)
|
void Render3DFloorPlane::Render(PolyRenderThread *thread)
|
||||||
{
|
{
|
||||||
FTextureID picnum = ceiling ? *fakeFloor->bottom.texture : *fakeFloor->top.texture;
|
FTextureID picnum = ceiling ? *fakeFloor->bottom.texture : *fakeFloor->top.texture;
|
||||||
FTexture *tex = TexMan(picnum);
|
auto tex = TexMan(picnum);
|
||||||
if (tex->UseType == ETextureType::Null)
|
if (!tex->isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PolyCameraLight *cameraLight = PolyCameraLight::Instance();
|
PolyCameraLight *cameraLight = PolyCameraLight::Instance();
|
||||||
|
@ -528,7 +528,7 @@ void Render3DFloorPlane::Render(PolyRenderThread *thread)
|
||||||
int actualextralight = foggy ? 0 : PolyRenderer::Instance()->Viewpoint.extralight << 4;
|
int actualextralight = foggy ? 0 : PolyRenderer::Instance()->Viewpoint.extralight << 4;
|
||||||
lightlevel = clamp(lightlevel + actualextralight, 0, 255);
|
lightlevel = clamp(lightlevel + actualextralight, 0, 255);
|
||||||
|
|
||||||
PolyPlaneUVTransform xform(ceiling ? fakeFloor->top.model->planes[sector_t::ceiling].xform : fakeFloor->top.model->planes[sector_t::floor].xform, tex);
|
PolyPlaneUVTransform xform(ceiling ? fakeFloor->top.model->planes[sector_t::ceiling].xform : fakeFloor->top.model->planes[sector_t::floor].xform, tex->GetSoftwareTexture());
|
||||||
|
|
||||||
TriVertex *vertices = thread->FrameMemory->AllocMemory<TriVertex>(sub->numlines);
|
TriVertex *vertices = thread->FrameMemory->AllocMemory<TriVertex>(sub->numlines);
|
||||||
if (ceiling)
|
if (ceiling)
|
||||||
|
@ -562,6 +562,6 @@ void Render3DFloorPlane::Render(PolyRenderThread *thread)
|
||||||
}
|
}
|
||||||
args.SetStencilTestValue(stencilValue);
|
args.SetStencilTestValue(stencilValue);
|
||||||
args.SetWriteStencil(true, stencilValue + 1);
|
args.SetWriteStencil(true, stencilValue + 1);
|
||||||
args.SetTexture(tex, DefaultRenderStyle());
|
args.SetTexture(tex->GetSoftwareTexture(), DefaultRenderStyle());
|
||||||
PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, sub->numlines, PolyDrawMode::TriangleFan);
|
PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, sub->numlines, PolyDrawMode::TriangleFan);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class PolyDrawSectorPortal;
|
||||||
class PolyPlaneUVTransform
|
class PolyPlaneUVTransform
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PolyPlaneUVTransform(const FTransform &transform, FTexture *tex);
|
PolyPlaneUVTransform(const FTransform &transform, FSoftwareTexture *tex);
|
||||||
|
|
||||||
TriVertex GetVertex(vertex_t *v1, double height) const
|
TriVertex GetVertex(vertex_t *v1, double height) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,7 +162,7 @@ void RenderPolyPlayerSprites::RenderRemainingSprites()
|
||||||
{
|
{
|
||||||
for (const PolyHWAccelPlayerSprite &sprite : AcceleratedSprites)
|
for (const PolyHWAccelPlayerSprite &sprite : AcceleratedSprites)
|
||||||
{
|
{
|
||||||
screen->DrawTexture(sprite.pic,
|
screen->DrawTexture(sprite.pic->GetTexture(),
|
||||||
viewwindowx + sprite.x1,
|
viewwindowx + sprite.x1,
|
||||||
viewwindowy + viewheight / 2 - sprite.texturemid * sprite.yscale - 0.5,
|
viewwindowy + viewheight / 2 - sprite.texturemid * sprite.yscale - 0.5,
|
||||||
DTA_DestWidthF, FIXED2DBL(sprite.pic->GetWidth() * sprite.xscale),
|
DTA_DestWidthF, FIXED2DBL(sprite.pic->GetWidth() * sprite.xscale),
|
||||||
|
@ -198,7 +198,8 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
||||||
spriteframe_t* sprframe;
|
spriteframe_t* sprframe;
|
||||||
FTextureID picnum;
|
FTextureID picnum;
|
||||||
uint16_t flip;
|
uint16_t flip;
|
||||||
FTexture* tex;
|
FTexture* ttex;
|
||||||
|
FSoftwareTexture* tex;
|
||||||
bool noaccel;
|
bool noaccel;
|
||||||
double alpha = owner->Alpha;
|
double alpha = owner->Alpha;
|
||||||
|
|
||||||
|
@ -226,11 +227,13 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
||||||
|
|
||||||
picnum = sprframe->Texture[0];
|
picnum = sprframe->Texture[0];
|
||||||
flip = sprframe->Flip & 1;
|
flip = sprframe->Flip & 1;
|
||||||
tex = TexMan(picnum);
|
ttex = TexMan(picnum);
|
||||||
|
|
||||||
if (tex->UseType == ETextureType::Null)
|
if (!ttex->isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
tex = ttex->GetSoftwareTexture();
|
||||||
|
|
||||||
if (pspr->firstTic)
|
if (pspr->firstTic)
|
||||||
{ // Can't interpolate the first tic.
|
{ // Can't interpolate the first tic.
|
||||||
pspr->firstTic = false;
|
pspr->firstTic = false;
|
||||||
|
@ -290,7 +293,7 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
||||||
|
|
||||||
vis.renderflags = owner->renderflags;
|
vis.renderflags = owner->renderflags;
|
||||||
|
|
||||||
vis.texturemid = (BASEYCENTER - sy) * tex->Scale.Y + tex->GetTopOffsetPo();
|
vis.texturemid = (BASEYCENTER - sy) * tex->GetScale().Y + tex->GetTopOffsetPo();
|
||||||
|
|
||||||
if (viewpoint.camera->player && (renderToCanvas ||
|
if (viewpoint.camera->player && (renderToCanvas ||
|
||||||
viewheight == renderTarget->GetHeight() ||
|
viewheight == renderTarget->GetHeight() ||
|
||||||
|
@ -304,20 +307,20 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
||||||
}
|
}
|
||||||
vis.x1 = x1 < 0 ? 0 : x1;
|
vis.x1 = x1 < 0 ? 0 : x1;
|
||||||
vis.x2 = x2 >= viewwidth ? viewwidth : x2;
|
vis.x2 = x2 >= viewwidth ? viewwidth : x2;
|
||||||
vis.xscale = FLOAT2FIXED(pspritexscale / tex->Scale.X);
|
vis.xscale = FLOAT2FIXED(pspritexscale / tex->GetScale().X);
|
||||||
vis.yscale = float(pspriteyscale / tex->Scale.Y);
|
vis.yscale = float(pspriteyscale / tex->GetScale().Y);
|
||||||
vis.pic = tex;
|
vis.pic = tex;
|
||||||
|
|
||||||
// If flip is used, provided that it's not already flipped (that would just invert itself)
|
// If flip is used, provided that it's not already flipped (that would just invert itself)
|
||||||
// (It's an XOR...)
|
// (It's an XOR...)
|
||||||
if (!(flip) != !(pspr->Flags & PSPF_FLIP))
|
if (!(flip) != !(pspr->Flags & PSPF_FLIP))
|
||||||
{
|
{
|
||||||
vis.xiscale = -FLOAT2FIXED(pspritexiscale * tex->Scale.X);
|
vis.xiscale = -FLOAT2FIXED(pspritexiscale * tex->GetScale().X);
|
||||||
vis.startfrac = (tex->GetWidth() << FRACBITS) - 1;
|
vis.startfrac = (tex->GetWidth() << FRACBITS) - 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vis.xiscale = FLOAT2FIXED(pspritexiscale * tex->Scale.X);
|
vis.xiscale = FLOAT2FIXED(pspritexiscale * tex->GetScale().X);
|
||||||
vis.startfrac = 0;
|
vis.startfrac = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
fixed_t xscale = 0;
|
fixed_t xscale = 0;
|
||||||
float yscale = 0.0f;
|
float yscale = 0.0f;
|
||||||
|
|
||||||
FTexture *pic = nullptr;
|
FSoftwareTexture *pic = nullptr;
|
||||||
|
|
||||||
fixed_t xiscale = 0;
|
fixed_t xiscale = 0;
|
||||||
fixed_t startfrac = 0;
|
fixed_t startfrac = 0;
|
||||||
|
@ -67,7 +67,7 @@ public:
|
||||||
class PolyHWAccelPlayerSprite
|
class PolyHWAccelPlayerSprite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FTexture *pic = nullptr;
|
FSoftwareTexture *pic = nullptr;
|
||||||
double texturemid = 0.0;
|
double texturemid = 0.0;
|
||||||
float yscale = 0.0f;
|
float yscale = 0.0f;
|
||||||
fixed_t xscale = 0;
|
fixed_t xscale = 0;
|
||||||
|
|
|
@ -63,7 +63,7 @@ void PolySkyDome::Render(PolyRenderThread *thread, const Mat4f &worldToView, con
|
||||||
float offsetBaseV = 0.25f;
|
float offsetBaseV = 0.25f;
|
||||||
|
|
||||||
float scaleFrontU = frameSetup.frontcyl / (float)frameSetup.frontskytex->GetWidth();
|
float scaleFrontU = frameSetup.frontcyl / (float)frameSetup.frontskytex->GetWidth();
|
||||||
float scaleFrontV = (float)frameSetup.frontskytex->Scale.Y * scaleBaseV;
|
float scaleFrontV = (float)frameSetup.frontskytex->GetScale().Y * scaleBaseV;
|
||||||
float offsetFrontU = (float)((frameSetup.frontpos / 65536.0 + frameSetup.frontcyl / 2) / frameSetup.frontskytex->GetWidth());
|
float offsetFrontU = (float)((frameSetup.frontpos / 65536.0 + frameSetup.frontcyl / 2) / frameSetup.frontskytex->GetWidth());
|
||||||
float offsetFrontV = (float)((frameSetup.skymid / frameSetup.frontskytex->GetHeight() + offsetBaseV) * scaleBaseV);
|
float offsetFrontV = (float)((frameSetup.skymid / frameSetup.frontskytex->GetHeight() + offsetBaseV) * scaleBaseV);
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ void PolySkyDome::RenderRow(PolyRenderThread *thread, PolyDrawArgs &args, int ro
|
||||||
PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleStrip);
|
PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleStrip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolySkyDome::RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap)
|
void PolySkyDome::RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args, FSoftwareTexture *skytex, int row, bool bottomCap)
|
||||||
{
|
{
|
||||||
uint32_t solid = skytex->GetSkyCapColor(bottomCap);
|
uint32_t solid = skytex->GetSkyCapColor(bottomCap);
|
||||||
uint8_t palsolid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)];
|
uint8_t palsolid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)];
|
||||||
|
@ -214,7 +214,7 @@ Mat4f PolySkyDome::GLSkyMath()
|
||||||
float x_offset = 0.0f;
|
float x_offset = 0.0f;
|
||||||
float y_offset = 0.0f;
|
float y_offset = 0.0f;
|
||||||
bool mirror = false;
|
bool mirror = false;
|
||||||
FTexture *tex = mCurrentSetup.frontskytex;
|
FSoftwareTexture *tex = mCurrentSetup.frontskytex;
|
||||||
|
|
||||||
int texh = 0;
|
int texh = 0;
|
||||||
int texw = 0;
|
int texw = 0;
|
||||||
|
@ -231,7 +231,7 @@ Mat4f PolySkyDome::GLSkyMath()
|
||||||
float yscale = 1.f;
|
float yscale = 1.f;
|
||||||
if (texh <= 128 && (level.flags & LEVEL_FORCETILEDSKY))
|
if (texh <= 128 && (level.flags & LEVEL_FORCETILEDSKY))
|
||||||
{
|
{
|
||||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->GetSkyOffset() + skyoffset)*skyoffsetfactor);
|
||||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.2f * 1.17f);
|
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.2f * 1.17f);
|
||||||
yscale = 240.f / texh;
|
yscale = 240.f / texh;
|
||||||
}
|
}
|
||||||
|
@ -249,12 +249,12 @@ Mat4f PolySkyDome::GLSkyMath()
|
||||||
}
|
}
|
||||||
else if (texh <= 240)
|
else if (texh <= 240)
|
||||||
{
|
{
|
||||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (200 - texh + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (200 - texh + tex->GetSkyOffset() + skyoffset)*skyoffsetfactor);
|
||||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.f + ((texh - 200.f) / 200.f) * 1.17f);
|
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.f + ((texh - 200.f) / 200.f) * 1.17f);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->GetSkyOffset() + skyoffset)*skyoffsetfactor);
|
||||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.2f * 1.17f);
|
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.2f * 1.17f);
|
||||||
yscale = 240.f / texh;
|
yscale = 240.f / texh;
|
||||||
}
|
}
|
||||||
|
@ -277,6 +277,14 @@ Mat4f PolySkyDome::GLSkyMath()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
static FSoftwareTexture *GetSWTex(FTextureID texid, bool allownull = true)
|
||||||
|
{
|
||||||
|
auto tex = TexMan(texid, true);
|
||||||
|
if (tex == nullptr) return nullptr;
|
||||||
|
if (!allownull && !tex->isValid()) return nullptr;
|
||||||
|
return tex->GetSoftwareTexture();
|
||||||
|
}
|
||||||
|
|
||||||
void PolySkySetup::Update()
|
void PolySkySetup::Update()
|
||||||
{
|
{
|
||||||
FTextureID sky1tex, sky2tex;
|
FTextureID sky1tex, sky2tex;
|
||||||
|
@ -299,9 +307,9 @@ void PolySkySetup::Update()
|
||||||
if (!(sectorSky & PL_SKYFLAT))
|
if (!(sectorSky & PL_SKYFLAT))
|
||||||
{ // use sky1
|
{ // use sky1
|
||||||
sky1:
|
sky1:
|
||||||
frontskytex = TexMan(sky1tex, true);
|
frontskytex = GetSWTex(sky1tex);
|
||||||
if (level.flags & LEVEL_DOUBLESKY)
|
if (level.flags & LEVEL_DOUBLESKY)
|
||||||
backskytex = TexMan(sky2tex, true);
|
backskytex = GetSWTex(sky2tex);
|
||||||
else
|
else
|
||||||
backskytex = nullptr;
|
backskytex = nullptr;
|
||||||
skyflip = false;
|
skyflip = false;
|
||||||
|
@ -312,7 +320,7 @@ void PolySkySetup::Update()
|
||||||
}
|
}
|
||||||
else if (sectorSky == PL_SKYFLAT)
|
else if (sectorSky == PL_SKYFLAT)
|
||||||
{ // use sky2
|
{ // use sky2
|
||||||
frontskytex = TexMan(sky2tex, true);
|
frontskytex = GetSWTex(sky2tex);
|
||||||
backskytex = nullptr;
|
backskytex = nullptr;
|
||||||
frontcyl = sky2cyl;
|
frontcyl = sky2cyl;
|
||||||
skyflip = false;
|
skyflip = false;
|
||||||
|
@ -338,8 +346,8 @@ void PolySkySetup::Update()
|
||||||
pos = side_t::top;
|
pos = side_t::top;
|
||||||
}
|
}
|
||||||
|
|
||||||
frontskytex = TexMan(s->GetTexture(pos), true);
|
frontskytex = GetSWTex(s->GetTexture(pos), false);
|
||||||
if (frontskytex == nullptr || frontskytex->UseType == ETextureType::Null)
|
if (frontskytex == nullptr)
|
||||||
{ // [RH] The blank texture: Use normal sky instead.
|
{ // [RH] The blank texture: Use normal sky instead.
|
||||||
goto sky1;
|
goto sky1;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +369,7 @@ void PolySkySetup::Update()
|
||||||
// allow old sky textures to be used.
|
// allow old sky textures to be used.
|
||||||
skyflip = l->args[2] ? false : true;
|
skyflip = l->args[2] ? false : true;
|
||||||
|
|
||||||
int frontxscale = int(frontskytex->Scale.X * 1024);
|
int frontxscale = int(frontskytex->GetScale().X * 1024);
|
||||||
frontcyl = MAX(frontskytex->GetWidth(), frontxscale);
|
frontcyl = MAX(frontskytex->GetWidth(), frontxscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@ public:
|
||||||
bool operator==(const PolySkySetup &that) const { return memcmp(this, &that, sizeof(PolySkySetup)) == 0; }
|
bool operator==(const PolySkySetup &that) const { return memcmp(this, &that, sizeof(PolySkySetup)) == 0; }
|
||||||
bool operator!=(const PolySkySetup &that) const { return memcmp(this, &that, sizeof(PolySkySetup)) != 0; }
|
bool operator!=(const PolySkySetup &that) const { return memcmp(this, &that, sizeof(PolySkySetup)) != 0; }
|
||||||
|
|
||||||
FTexture *frontskytex = nullptr;
|
FSoftwareTexture *frontskytex = nullptr;
|
||||||
FTexture *backskytex = nullptr;
|
FSoftwareTexture *backskytex = nullptr;
|
||||||
bool skyflip = 0;
|
bool skyflip = 0;
|
||||||
int frontpos = 0;
|
int frontpos = 0;
|
||||||
int backpos = 0;
|
int backpos = 0;
|
||||||
|
@ -58,7 +58,7 @@ private:
|
||||||
void CreateSkyHemisphere(bool zflip);
|
void CreateSkyHemisphere(bool zflip);
|
||||||
void CreateDome();
|
void CreateDome();
|
||||||
void RenderRow(PolyRenderThread *thread, PolyDrawArgs &args, int row, uint32_t capcolor, uint8_t capcolorindex);
|
void RenderRow(PolyRenderThread *thread, PolyDrawArgs &args, int row, uint32_t capcolor, uint8_t capcolorindex);
|
||||||
void RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap);
|
void RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args, FSoftwareTexture *skytex, int row, bool bottomCap);
|
||||||
|
|
||||||
TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0);
|
TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0);
|
||||||
|
|
||||||
|
|
|
@ -49,13 +49,13 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right)
|
||||||
DVector3 pos = thing->InterpolatedPosition(viewpoint.TicFrac);
|
DVector3 pos = thing->InterpolatedPosition(viewpoint.TicFrac);
|
||||||
|
|
||||||
bool flipTextureX = false;
|
bool flipTextureX = false;
|
||||||
FTexture *tex = GetSpriteTexture(thing, flipTextureX);
|
FSoftwareTexture *tex = GetSpriteTexture(thing, flipTextureX);
|
||||||
if (tex == nullptr)
|
if (tex == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
DVector2 spriteScale = thing->Scale;
|
DVector2 spriteScale = thing->Scale;
|
||||||
double thingxscalemul = spriteScale.X / tex->Scale.X;
|
double thingxscalemul = spriteScale.X / tex->GetScale().X;
|
||||||
double thingyscalemul = spriteScale.Y / tex->Scale.Y;
|
double thingyscalemul = spriteScale.Y / tex->GetScale().Y;
|
||||||
|
|
||||||
double spriteWidth = thingxscalemul * tex->GetWidth();
|
double spriteWidth = thingxscalemul * tex->GetWidth();
|
||||||
double spriteHeight = thingyscalemul * tex->GetHeight();
|
double spriteHeight = thingyscalemul * tex->GetHeight();
|
||||||
|
@ -105,11 +105,11 @@ void RenderPolySprite::Render(PolyRenderThread *thread, AActor *thing, subsector
|
||||||
posZ += thing->GetBobOffset(viewpoint.TicFrac);
|
posZ += thing->GetBobOffset(viewpoint.TicFrac);
|
||||||
|
|
||||||
bool flipTextureX = false;
|
bool flipTextureX = false;
|
||||||
FTexture *tex = GetSpriteTexture(thing, flipTextureX);
|
FSoftwareTexture *tex = GetSpriteTexture(thing, flipTextureX);
|
||||||
if (tex == nullptr || tex->UseType == ETextureType::Null)
|
if (tex == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
double thingyscalemul = thing->Scale.Y / tex->Scale.Y;
|
double thingyscalemul = thing->Scale.Y / tex->GetScale().Y;
|
||||||
double spriteHeight = thingyscalemul * tex->GetHeight();
|
double spriteHeight = thingyscalemul * tex->GetHeight();
|
||||||
|
|
||||||
posZ -= (tex->GetHeight() - tex->GetTopOffsetPo()) * thingyscalemul;
|
posZ -= (tex->GetHeight() - tex->GetTopOffsetPo()) * thingyscalemul;
|
||||||
|
@ -302,7 +302,7 @@ bool RenderPolySprite::IsThingCulled(AActor *thing)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
|
FSoftwareTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
|
||||||
{
|
{
|
||||||
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||||
flipX = false;
|
flipX = false;
|
||||||
|
@ -312,16 +312,17 @@ FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
|
||||||
|
|
||||||
if (thing->picnum.isValid())
|
if (thing->picnum.isValid())
|
||||||
{
|
{
|
||||||
FTexture *tex = TexMan(thing->picnum);
|
FTexture *ttex = TexMan(thing->picnum);
|
||||||
if (tex->UseType == ETextureType::Null)
|
if (!ttex || !ttex->isValid())
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
FSoftwareTexture *tex = ttex->GetSoftwareTexture();
|
||||||
|
|
||||||
if (tex->Rotations != 0xFFFF)
|
if (ttex->GetRotations() != 0xFFFF)
|
||||||
{
|
{
|
||||||
// choose a different rotation based on player view
|
// choose a different rotation based on player view
|
||||||
spriteframe_t *sprframe = &SpriteFrames[tex->Rotations];
|
spriteframe_t *sprframe = &SpriteFrames[ttex->GetRotations()];
|
||||||
DVector3 pos = thing->InterpolatedPosition(viewpoint.TicFrac);
|
DVector3 pos = thing->InterpolatedPosition(viewpoint.TicFrac);
|
||||||
pos.Z += thing->GetBobOffset(viewpoint.TicFrac);
|
pos.Z += thing->GetBobOffset(viewpoint.TicFrac);
|
||||||
DAngle ang = (pos - viewpoint.Pos).Angle();
|
DAngle ang = (pos - viewpoint.Pos).Angle();
|
||||||
|
@ -335,7 +336,13 @@ FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
|
||||||
rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28;
|
rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28;
|
||||||
}
|
}
|
||||||
flipX = (sprframe->Flip & (1 << rot)) != 0;
|
flipX = (sprframe->Flip & (1 << rot)) != 0;
|
||||||
tex = TexMan[sprframe->Texture[rot]]; // Do not animate the rotation
|
ttex = TexMan[sprframe->Texture[rot]]; // Do not animate the rotation
|
||||||
|
tex = ttex->GetSoftwareTexture();
|
||||||
|
if (!ttex || !ttex->isValid())
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
FSoftwareTexture *tex = ttex->GetSoftwareTexture();
|
||||||
}
|
}
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
@ -364,7 +371,7 @@ FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
|
||||||
DAngle sprangle = thing->GetSpriteAngle((pos - viewpoint.Pos).Angle(), viewpoint.TicFrac);
|
DAngle sprangle = thing->GetSpriteAngle((pos - viewpoint.Pos).Angle(), viewpoint.TicFrac);
|
||||||
FTextureID tex = sprdef->GetSpriteFrame(thing->frame, -1, sprangle, &flipX);
|
FTextureID tex = sprdef->GetSpriteFrame(thing->frame, -1, sprangle, &flipX);
|
||||||
if (!tex.isValid()) return nullptr;
|
if (!tex.isValid()) return nullptr;
|
||||||
return TexMan[tex];
|
return TexMan[tex]->GetSoftwareTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
|
|
||||||
static bool GetLine(AActor *thing, DVector2 &left, DVector2 &right);
|
static bool GetLine(AActor *thing, DVector2 &left, DVector2 &right);
|
||||||
static bool IsThingCulled(AActor *thing);
|
static bool IsThingCulled(AActor *thing);
|
||||||
static FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX);
|
static FSoftwareTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static double PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, double spriteheight, double z);
|
static double PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, double spriteheight, double z);
|
||||||
|
|
|
@ -172,7 +172,7 @@ bool RenderPolyWall::RenderLine(PolyRenderThread *thread, seg_t *line, sector_t
|
||||||
wall.FogBoundary = IsFogBoundary(frontsector, backsector);
|
wall.FogBoundary = IsFogBoundary(frontsector, backsector);
|
||||||
|
|
||||||
FTexture *midtex = TexMan(line->sidedef->GetTexture(side_t::mid), true);
|
FTexture *midtex = TexMan(line->sidedef->GetTexture(side_t::mid), true);
|
||||||
if ((midtex && midtex->UseType != ETextureType::Null) || wall.FogBoundary)
|
if ((midtex && midtex->isValid()) || wall.FogBoundary)
|
||||||
translucentWallsOutput.push_back(thread->FrameMemory->NewObject<PolyTranslucentWall>(wall));
|
translucentWallsOutput.push_back(thread->FrameMemory->NewObject<PolyTranslucentWall>(wall));
|
||||||
|
|
||||||
if (polyportal)
|
if (polyportal)
|
||||||
|
@ -526,10 +526,10 @@ void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2)
|
||||||
v2.v = texv1 * inv_t2 + texv2 * t2;
|
v2.v = texv1 * inv_t2 + texv2 * t2;
|
||||||
}
|
}
|
||||||
|
|
||||||
FTexture *RenderPolyWall::GetTexture(const line_t *line, const side_t *side, side_t::ETexpart texpart)
|
FSoftwareTexture *RenderPolyWall::GetTexture(const line_t *line, const side_t *side, side_t::ETexpart texpart)
|
||||||
{
|
{
|
||||||
FTexture *tex = TexMan(side->GetTexture(texpart), true);
|
FTexture *tex = TexMan(side->GetTexture(texpart), true);
|
||||||
if (tex == nullptr || tex->UseType == ETextureType::Null)
|
if (tex == nullptr || !tex->isValid())
|
||||||
{
|
{
|
||||||
// Mapping error. Doom floodfills this with a plane.
|
// Mapping error. Doom floodfills this with a plane.
|
||||||
// This code doesn't do that, but at least it uses the "right" texture..
|
// This code doesn't do that, but at least it uses the "right" texture..
|
||||||
|
@ -549,10 +549,10 @@ FTexture *RenderPolyWall::GetTexture(const line_t *line, const side_t *side, sid
|
||||||
tex = TexMan(line->frontsector->GetTexture(sector_t::floor), true);
|
tex = TexMan(line->frontsector->GetTexture(sector_t::floor), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tex == nullptr || tex->UseType == ETextureType::Null)
|
if (tex == nullptr || !tex->isValid())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return tex;
|
return tex? tex->GetSoftwareTexture() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int RenderPolyWall::GetLightLevel()
|
int RenderPolyWall::GetLightLevel()
|
||||||
|
@ -572,13 +572,13 @@ int RenderPolyWall::GetLightLevel()
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
PolyWallTextureCoordsU::PolyWallTextureCoordsU(FTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart wallpart)
|
PolyWallTextureCoordsU::PolyWallTextureCoordsU(FSoftwareTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart wallpart)
|
||||||
{
|
{
|
||||||
// Calculate the U texture coordinate for the line
|
// Calculate the U texture coordinate for the line
|
||||||
double lineu1 = side->GetTextureXOffset(wallpart);
|
double lineu1 = side->GetTextureXOffset(wallpart);
|
||||||
double lineu2 = side->GetTextureXOffset(wallpart) + line->sidedef[0]->TexelLength * side->GetTextureXScale(wallpart);
|
double lineu2 = side->GetTextureXOffset(wallpart) + line->sidedef[0]->TexelLength * side->GetTextureXScale(wallpart);
|
||||||
lineu1 *= tex->Scale.X / tex->GetWidth();
|
lineu1 *= tex->GetScale().X / tex->GetWidth();
|
||||||
lineu2 *= tex->Scale.X / tex->GetWidth();
|
lineu2 *= tex->GetScale().X / tex->GetWidth();
|
||||||
|
|
||||||
// Calculate where we are on the lineseg
|
// Calculate where we are on the lineseg
|
||||||
double t1, t2;
|
double t1, t2;
|
||||||
|
@ -606,11 +606,11 @@ PolyWallTextureCoordsU::PolyWallTextureCoordsU(FTexture *tex, const seg_t *lines
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
PolyWallTextureCoordsV::PolyWallTextureCoordsV(FTexture *tex, const line_t *line, const side_t *side, side_t::ETexpart wallpart, double topz, double bottomz, double unpeggedceil, double topTexZ, double bottomTexZ)
|
PolyWallTextureCoordsV::PolyWallTextureCoordsV(FSoftwareTexture *tex, const line_t *line, const side_t *side, side_t::ETexpart wallpart, double topz, double bottomz, double unpeggedceil, double topTexZ, double bottomTexZ)
|
||||||
{
|
{
|
||||||
double yoffset = side->GetTextureYOffset(wallpart);
|
double yoffset = side->GetTextureYOffset(wallpart);
|
||||||
if (tex->bWorldPanning)
|
if (tex->useWorldPanning())
|
||||||
yoffset *= side->GetTextureYScale(wallpart) * tex->Scale.Y;
|
yoffset *= side->GetTextureYScale(wallpart) * tex->GetScale().Y;
|
||||||
|
|
||||||
switch (wallpart)
|
switch (wallpart)
|
||||||
{
|
{
|
||||||
|
@ -626,8 +626,8 @@ PolyWallTextureCoordsV::PolyWallTextureCoordsV(FTexture *tex, const line_t *line
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
v1 *= tex->Scale.Y / tex->GetHeight();
|
v1 *= tex->GetScale().Y / tex->GetHeight();
|
||||||
v2 *= tex->Scale.Y / tex->GetHeight();
|
v2 *= tex->GetScale().Y / tex->GetHeight();
|
||||||
|
|
||||||
double texZHeight = (bottomTexZ - topTexZ);
|
double texZHeight = (bottomTexZ - topTexZ);
|
||||||
if (texZHeight > 0.0f || texZHeight < -0.0f)
|
if (texZHeight > 0.0f || texZHeight < -0.0f)
|
||||||
|
@ -641,12 +641,12 @@ PolyWallTextureCoordsV::PolyWallTextureCoordsV(FTexture *tex, const line_t *line
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyWallTextureCoordsV::CalcVTopPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset)
|
void PolyWallTextureCoordsV::CalcVTopPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset)
|
||||||
{
|
{
|
||||||
bool pegged = (line->flags & ML_DONTPEGTOP) == 0;
|
bool pegged = (line->flags & ML_DONTPEGTOP) == 0;
|
||||||
if (pegged) // bottom to top
|
if (pegged) // bottom to top
|
||||||
{
|
{
|
||||||
double texHeight = tex->GetHeight() / tex->Scale.Y;
|
double texHeight = tex->GetHeight() / tex->GetScale().Y;
|
||||||
v1 = (topz - bottomz) * side->GetTextureYScale(side_t::top) - yoffset;
|
v1 = (topz - bottomz) * side->GetTextureYScale(side_t::top) - yoffset;
|
||||||
v2 = -yoffset;
|
v2 = -yoffset;
|
||||||
v1 = texHeight - v1;
|
v1 = texHeight - v1;
|
||||||
|
@ -659,7 +659,7 @@ void PolyWallTextureCoordsV::CalcVTopPart(FTexture *tex, const line_t *line, con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyWallTextureCoordsV::CalcVMidPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset)
|
void PolyWallTextureCoordsV::CalcVMidPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset)
|
||||||
{
|
{
|
||||||
bool pegged = (line->flags & ML_DONTPEGBOTTOM) == 0;
|
bool pegged = (line->flags & ML_DONTPEGBOTTOM) == 0;
|
||||||
if (pegged) // top to bottom
|
if (pegged) // top to bottom
|
||||||
|
@ -669,7 +669,7 @@ void PolyWallTextureCoordsV::CalcVMidPart(FTexture *tex, const line_t *line, con
|
||||||
}
|
}
|
||||||
else // bottom to top
|
else // bottom to top
|
||||||
{
|
{
|
||||||
double texHeight = tex->GetHeight() / tex->Scale.Y;
|
double texHeight = tex->GetHeight() / tex->GetScale().Y;
|
||||||
v1 = yoffset - (topz - bottomz) * side->GetTextureYScale(side_t::mid);
|
v1 = yoffset - (topz - bottomz) * side->GetTextureYScale(side_t::mid);
|
||||||
v2 = yoffset;
|
v2 = yoffset;
|
||||||
v1 = texHeight + v1;
|
v1 = texHeight + v1;
|
||||||
|
@ -677,7 +677,7 @@ void PolyWallTextureCoordsV::CalcVMidPart(FTexture *tex, const line_t *line, con
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolyWallTextureCoordsV::CalcVBottomPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double unpeggedceil, double yoffset)
|
void PolyWallTextureCoordsV::CalcVBottomPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double unpeggedceil, double yoffset)
|
||||||
{
|
{
|
||||||
bool pegged = (line->flags & ML_DONTPEGBOTTOM) == 0;
|
bool pegged = (line->flags & ML_DONTPEGBOTTOM) == 0;
|
||||||
if (pegged) // top to bottom
|
if (pegged) // top to bottom
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
const line_t *LineSegLine = nullptr;
|
const line_t *LineSegLine = nullptr;
|
||||||
const line_t *Line = nullptr;
|
const line_t *Line = nullptr;
|
||||||
const side_t *Side = nullptr;
|
const side_t *Side = nullptr;
|
||||||
FTexture *Texture = nullptr;
|
FSoftwareTexture *Texture = nullptr;
|
||||||
side_t::ETexpart Wallpart = side_t::mid;
|
side_t::ETexpart Wallpart = side_t::mid;
|
||||||
double TopTexZ = 0.0;
|
double TopTexZ = 0.0;
|
||||||
double BottomTexZ = 0.0;
|
double BottomTexZ = 0.0;
|
||||||
|
@ -72,13 +72,13 @@ private:
|
||||||
void SetDynLights(PolyRenderThread *thread, PolyDrawArgs &args);
|
void SetDynLights(PolyRenderThread *thread, PolyDrawArgs &args);
|
||||||
|
|
||||||
static bool IsFogBoundary(sector_t *front, sector_t *back);
|
static bool IsFogBoundary(sector_t *front, sector_t *back);
|
||||||
static FTexture *GetTexture(const line_t *Line, const side_t *Side, side_t::ETexpart texpart);
|
static FSoftwareTexture *GetTexture(const line_t *Line, const side_t *Side, side_t::ETexpart texpart);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PolyWallTextureCoordsU
|
class PolyWallTextureCoordsU
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PolyWallTextureCoordsU(FTexture *tex, const seg_t *lineseg, const line_t *linesegline, const side_t *side, side_t::ETexpart wallpart);
|
PolyWallTextureCoordsU(FSoftwareTexture *tex, const seg_t *lineseg, const line_t *linesegline, const side_t *side, side_t::ETexpart wallpart);
|
||||||
|
|
||||||
double u1, u2;
|
double u1, u2;
|
||||||
};
|
};
|
||||||
|
@ -86,14 +86,14 @@ public:
|
||||||
class PolyWallTextureCoordsV
|
class PolyWallTextureCoordsV
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PolyWallTextureCoordsV(FTexture *tex, const line_t *line, const side_t *side, side_t::ETexpart wallpart, double topz, double bottomz, double unpeggedceil, double topTexZ, double bottomTexZ);
|
PolyWallTextureCoordsV(FSoftwareTexture *tex, const line_t *line, const side_t *side, side_t::ETexpart wallpart, double topz, double bottomz, double unpeggedceil, double topTexZ, double bottomTexZ);
|
||||||
|
|
||||||
double v1, v2;
|
double v1, v2;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CalcVTopPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset);
|
void CalcVTopPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset);
|
||||||
void CalcVMidPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset);
|
void CalcVMidPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset);
|
||||||
void CalcVBottomPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double unpeggedceil, double yoffset);
|
void CalcVBottomPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double unpeggedceil, double yoffset);
|
||||||
};
|
};
|
||||||
|
|
||||||
class PolyTranslucentWall : public PolyTranslucentObject
|
class PolyTranslucentWall : public PolyTranslucentObject
|
||||||
|
|
|
@ -40,13 +40,13 @@ void RenderPolyWallSprite::Render(PolyRenderThread *thread, AActor *thing, subse
|
||||||
pos.Z += thing->GetBobOffset(viewpoint.TicFrac);
|
pos.Z += thing->GetBobOffset(viewpoint.TicFrac);
|
||||||
|
|
||||||
bool flipTextureX = false;
|
bool flipTextureX = false;
|
||||||
FTexture *tex = RenderPolySprite::GetSpriteTexture(thing, flipTextureX);
|
FSoftwareTexture *tex = RenderPolySprite::GetSpriteTexture(thing, flipTextureX);
|
||||||
if (tex == nullptr || tex->UseType == ETextureType::Null)
|
if (tex == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DVector2 spriteScale = thing->Scale;
|
DVector2 spriteScale = thing->Scale;
|
||||||
double thingxscalemul = spriteScale.X / tex->Scale.X;
|
double thingxscalemul = spriteScale.X / tex->GetScale().X;
|
||||||
double thingyscalemul = spriteScale.Y / tex->Scale.Y;
|
double thingyscalemul = spriteScale.Y / tex->GetScale().Y;
|
||||||
double spriteHeight = thingyscalemul * tex->GetHeight();
|
double spriteHeight = thingyscalemul * tex->GetHeight();
|
||||||
|
|
||||||
DAngle ang = thing->Angles.Yaw + 90;
|
DAngle ang = thing->Angles.Yaw + 90;
|
||||||
|
@ -91,8 +91,8 @@ void RenderPolyWallSprite::Render(PolyRenderThread *thread, AActor *thing, subse
|
||||||
vertices[i].y = (float)p.Y;
|
vertices[i].y = (float)p.Y;
|
||||||
vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second);
|
vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second);
|
||||||
vertices[i].w = 1.0f;
|
vertices[i].w = 1.0f;
|
||||||
vertices[i].u = (float)(offsets[i].first * tex->Scale.X);
|
vertices[i].u = (float)(offsets[i].first * tex->GetScale().X);
|
||||||
vertices[i].v = (float)((1.0f - offsets[i].second) * tex->Scale.Y);
|
vertices[i].v = (float)((1.0f - offsets[i].second) * tex->GetScale().Y);
|
||||||
if (flipTextureX)
|
if (flipTextureX)
|
||||||
vertices[i].u = 1.0f - vertices[i].u;
|
vertices[i].u = 1.0f - vertices[i].u;
|
||||||
}
|
}
|
||||||
|
|
|
@ -652,13 +652,16 @@ bool I_SetCursor(FTexture* cursorpic)
|
||||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSCursor* cursor = nil;
|
NSCursor* cursor = nil;
|
||||||
|
|
||||||
if (NULL != cursorpic && ETextureType::Null != cursorpic->UseType)
|
if (NULL != cursorpic && cursorpic->isValid())
|
||||||
{
|
{
|
||||||
// Create bitmap image representation
|
// Create bitmap image representation
|
||||||
|
|
||||||
const NSInteger imageWidth = cursorpic->GetWidth();
|
int w, h;
|
||||||
const NSInteger imageHeight = cursorpic->GetHeight();
|
auto sbuffer = cursorpic->CreateTexBuffer(0, w, h);
|
||||||
const NSInteger imagePitch = imageWidth * 4;
|
|
||||||
|
const NSInteger imageWidth = w;
|
||||||
|
const NSInteger imageHeight = h;
|
||||||
|
const NSInteger imagePitch = w * 4;
|
||||||
|
|
||||||
NSBitmapImageRep* bitmapImageRep = [NSBitmapImageRep alloc];
|
NSBitmapImageRep* bitmapImageRep = [NSBitmapImageRep alloc];
|
||||||
[bitmapImageRep initWithBitmapDataPlanes:NULL
|
[bitmapImageRep initWithBitmapDataPlanes:NULL
|
||||||
|
@ -675,20 +678,15 @@ bool I_SetCursor(FTexture* cursorpic)
|
||||||
// Load bitmap data to representation
|
// Load bitmap data to representation
|
||||||
|
|
||||||
uint8_t* buffer = [bitmapImageRep bitmapData];
|
uint8_t* buffer = [bitmapImageRep bitmapData];
|
||||||
memset(buffer, 0, imagePitch * imageHeight);
|
memcpy(buffer, sbuffer, imagePitch * imageHeight);
|
||||||
|
delete [] sbuffer;
|
||||||
FBitmap bitmap(buffer, imagePitch, imageWidth, imageHeight);
|
|
||||||
cursorpic->CopyTrueColorPixels(&bitmap, 0, 0);
|
|
||||||
|
|
||||||
// Swap red and blue components in each pixel
|
// Swap red and blue components in each pixel
|
||||||
|
|
||||||
for (size_t i = 0; i < size_t(imageWidth * imageHeight); ++i)
|
for (size_t i = 0; i < size_t(imageWidth * imageHeight); ++i)
|
||||||
{
|
{
|
||||||
const size_t offset = i * 4;
|
const size_t offset = i * 4;
|
||||||
|
std::swap(buffer[offset ], buffer[offset + 2]);
|
||||||
const uint8_t temp = buffer[offset ];
|
|
||||||
buffer[offset ] = buffer[offset + 2];
|
|
||||||
buffer[offset + 2] = temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create image from representation and set it as cursor
|
// Create image from representation and set it as cursor
|
||||||
|
|
|
@ -73,9 +73,7 @@ static void ParseVavoomSkybox()
|
||||||
int facecount=0;
|
int facecount=0;
|
||||||
int maplump = -1;
|
int maplump = -1;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
FSkyBox * sb = new FSkyBox;
|
FSkyBox * sb = new FSkyBox(sc.String);
|
||||||
sb->Name = sc.String;
|
|
||||||
sb->Name.ToUpper();
|
|
||||||
sb->fliptop = true;
|
sb->fliptop = true;
|
||||||
sc.MustGetStringName("{");
|
sc.MustGetStringName("{");
|
||||||
while (!sc.CheckString("}"))
|
while (!sc.CheckString("}"))
|
||||||
|
@ -91,7 +89,7 @@ static void ParseVavoomSkybox()
|
||||||
FTexture *tex = TexMan.FindTexture(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny);
|
FTexture *tex = TexMan.FindTexture(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny);
|
||||||
if (tex == NULL)
|
if (tex == NULL)
|
||||||
{
|
{
|
||||||
sc.ScriptMessage("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name.GetChars());
|
sc.ScriptMessage("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->GetName().GetChars());
|
||||||
error = true;
|
error = true;
|
||||||
}
|
}
|
||||||
sb->faces[facecount] = tex;
|
sb->faces[facecount] = tex;
|
||||||
|
@ -101,7 +99,7 @@ static void ParseVavoomSkybox()
|
||||||
}
|
}
|
||||||
if (facecount != 6)
|
if (facecount != 6)
|
||||||
{
|
{
|
||||||
sc.ScriptError("%s: Skybox definition requires 6 faces", sb->Name.GetChars());
|
sc.ScriptError("%s: Skybox definition requires 6 faces", sb->GetName().GetChars());
|
||||||
}
|
}
|
||||||
sb->SetSize();
|
sb->SetSize();
|
||||||
if (!error) TexMan.AddTexture(sb);
|
if (!error) TexMan.AddTexture(sb);
|
||||||
|
@ -1140,14 +1138,6 @@ class GLDefsParser
|
||||||
|
|
||||||
if (bmtex != NULL)
|
if (bmtex != NULL)
|
||||||
{
|
{
|
||||||
/* I do not think this is needed any longer
|
|
||||||
if (tex->bWarped != 0)
|
|
||||||
{
|
|
||||||
Printf("Cannot combine warping with brightmap on texture '%s'\n", tex->Name.GetChars());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
bmtex->bMasked = false;
|
bmtex->bMasked = false;
|
||||||
tex->Brightmap = bmtex;
|
tex->Brightmap = bmtex;
|
||||||
}
|
}
|
||||||
|
@ -1367,7 +1357,7 @@ class GLDefsParser
|
||||||
usershader.defines.AppendFormat("#define %s texture%d\n", texNameList[i].GetChars(), texNameIndex[i] + firstUserTexture);
|
usershader.defines.AppendFormat("#define %s texture%d\n", texNameList[i].GetChars(), texNameIndex[i] + firstUserTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tex->bWarped != 0)
|
if (tex->isWarped() != 0)
|
||||||
{
|
{
|
||||||
Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars());
|
Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars());
|
||||||
return;
|
return;
|
||||||
|
@ -1608,7 +1598,7 @@ class GLDefsParser
|
||||||
|
|
||||||
if (desc.shader.IsNotEmpty())
|
if (desc.shader.IsNotEmpty())
|
||||||
{
|
{
|
||||||
if (tex->bWarped != 0)
|
if (tex->isWarped() != 0)
|
||||||
{
|
{
|
||||||
Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars());
|
Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -122,7 +122,7 @@ static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool
|
||||||
|
|
||||||
if (frame >= MAX_SPRITE_FRAMES || rotation > 16)
|
if (frame >= MAX_SPRITE_FRAMES || rotation > 16)
|
||||||
{
|
{
|
||||||
Printf (TEXTCOLOR_RED "R_InstallSpriteLump: Bad frame characters in lump %s\n", TexMan[lump]->Name.GetChars());
|
Printf (TEXTCOLOR_RED "R_InstallSpriteLump: Bad frame characters in lump %s\n", TexMan[lump]->GetName().GetChars());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool
|
||||||
|
|
||||||
|
|
||||||
// [RH] Seperated out of R_InitSpriteDefs()
|
// [RH] Seperated out of R_InitSpriteDefs()
|
||||||
static void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe)
|
void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe)
|
||||||
{
|
{
|
||||||
int frame;
|
int frame;
|
||||||
int framestart;
|
int framestart;
|
||||||
|
|
|
@ -100,7 +100,7 @@ void R_InitSkyMap ()
|
||||||
if (skytex1 == nullptr)
|
if (skytex1 == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((level.flags & LEVEL_DOUBLESKY) && skytex1->GetHeight() != skytex2->GetHeight())
|
if ((level.flags & LEVEL_DOUBLESKY) && skytex1->GetDisplayHeight() != skytex2->GetDisplayHeight())
|
||||||
{
|
{
|
||||||
Printf (TEXTCOLOR_BOLD "Both sky textures must be the same height." TEXTCOLOR_NORMAL "\n");
|
Printf (TEXTCOLOR_BOLD "Both sky textures must be the same height." TEXTCOLOR_NORMAL "\n");
|
||||||
sky2texture = sky1texture;
|
sky2texture = sky1texture;
|
||||||
|
@ -119,20 +119,30 @@ void R_InitSkyMap ()
|
||||||
// the screen when looking fully up.
|
// the screen when looking fully up.
|
||||||
// h > 200: Unstretched, but the baseline is shifted down so that the top
|
// h > 200: Unstretched, but the baseline is shifted down so that the top
|
||||||
// of the texture is at the top of the screen when looking fully up.
|
// of the texture is at the top of the screen when looking fully up.
|
||||||
skyheight = skytex1->GetScaledHeight();
|
skyheight = skytex1->GetDisplayHeight();
|
||||||
skystretch = false;
|
|
||||||
skytexturemid = 0;
|
|
||||||
if (skyheight >= 128 && skyheight < 200)
|
if (skyheight >= 128 && skyheight < 200)
|
||||||
{
|
{
|
||||||
skystretch = (r_skymode == 1
|
skystretch = (r_skymode == 1
|
||||||
&& skyheight >= 128
|
&& skyheight >= 128
|
||||||
&& level.IsFreelookAllowed()
|
&& level.IsFreelookAllowed()
|
||||||
&& !(level.flags & LEVEL_FORCETILEDSKY)) ? 1 : 0;
|
&& !(level.flags & LEVEL_FORCETILEDSKY)) ? 1 : 0;
|
||||||
|
}
|
||||||
|
else skystretch = false;
|
||||||
|
|
||||||
|
// Anything below is only for the software renderer (todo - move it there!)
|
||||||
|
// Note: I don't think it is good that this stuff gets cached globally.
|
||||||
|
// For something that only needs to be once per frame it is rather pointless and makes it hard to swap out the underlying textures based on user settings.
|
||||||
|
FSoftwareTexture *sskytex1 = skytex1->GetSoftwareTexture();
|
||||||
|
FSoftwareTexture *sskytex2 = skytex2->GetSoftwareTexture();
|
||||||
|
skytexturemid = 0;
|
||||||
|
if (skyheight >= 128 && skyheight < 200)
|
||||||
|
{
|
||||||
skytexturemid = -28;
|
skytexturemid = -28;
|
||||||
}
|
}
|
||||||
else if (skyheight > 200)
|
else if (skyheight > 200)
|
||||||
{
|
{
|
||||||
skytexturemid = (200 - skyheight) * skytex1->Scale.Y +((r_skymode == 2 && !(level.flags & LEVEL_FORCETILEDSKY)) ? skytex1->SkyOffset + testskyoffset : 0);
|
skytexturemid = (200 - skyheight) * sskytex1->GetScale().Y +((r_skymode == 2 && !(level.flags & LEVEL_FORCETILEDSKY)) ? skytex1->GetSkyOffset() + testskyoffset : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (viewwidth != 0 && viewheight != 0)
|
if (viewwidth != 0 && viewheight != 0)
|
||||||
|
@ -155,8 +165,8 @@ void R_InitSkyMap ()
|
||||||
// giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024,
|
// giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024,
|
||||||
// we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of
|
// we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of
|
||||||
// the texture as the cylinder's circumfrence.
|
// the texture as the cylinder's circumfrence.
|
||||||
sky1cyl = MAX(skytex1->GetWidth(), fixed_t(skytex1->Scale.X * 1024));
|
sky1cyl = MAX(sskytex1->GetWidth(), fixed_t(sskytex1->GetScale().X * 1024));
|
||||||
sky2cyl = MAX(skytex2->GetWidth(), fixed_t(skytex2->Scale.Y * 1024));
|
sky2cyl = MAX(sskytex2->GetWidth(), fixed_t(sskytex2->GetScale().Y * 1024));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1108,7 +1108,7 @@ void SetCameraToTexture(AActor *viewpoint, const FString &texturename, double fo
|
||||||
{
|
{
|
||||||
// Only proceed if the texture actually has a canvas.
|
// Only proceed if the texture actually has a canvas.
|
||||||
FTexture *tex = TexMan[textureid];
|
FTexture *tex = TexMan[textureid];
|
||||||
if (tex && tex->bHasCanvas)
|
if (tex && tex->isCanvas())
|
||||||
{
|
{
|
||||||
FCanvasTextureInfo::Add(viewpoint, textureid, fov);
|
FCanvasTextureInfo::Add(viewpoint, textureid, fov);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ static void CastCo2S(FString *a, int b) { PalEntry c(b); a->Format("%02x %02x %0
|
||||||
static int CastS2So(FString *b) { return FSoundID(*b); }
|
static int CastS2So(FString *b) { return FSoundID(*b); }
|
||||||
static void CastSo2S(FString *a, int b) { *a = S_sfx[b].name; }
|
static void CastSo2S(FString *a, int b) { *a = S_sfx[b].name; }
|
||||||
static void CastSID2S(FString *a, unsigned int b) { *a = (b >= sprites.Size()) ? "TNT1" : sprites[b].name; }
|
static void CastSID2S(FString *a, unsigned int b) { *a = (b >= sprites.Size()) ? "TNT1" : sprites[b].name; }
|
||||||
static void CastTID2S(FString *a, int b) { auto tex = TexMan[*(FTextureID*)&b]; *a = (tex == nullptr) ? "(null)" : tex->Name.GetChars(); }
|
static void CastTID2S(FString *a, int b) { auto tex = TexMan[*(FTextureID*)&b]; *a = (tex == nullptr) ? "(null)" : tex->GetName().GetChars(); }
|
||||||
|
|
||||||
void JitCompiler::EmitCAST()
|
void JitCompiler::EmitCAST()
|
||||||
{
|
{
|
||||||
|
|
|
@ -1875,7 +1875,7 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
||||||
{
|
{
|
||||||
ASSERTS(a); ASSERTD(b);
|
ASSERTS(a); ASSERTD(b);
|
||||||
auto tex = TexMan[*(FTextureID*)&(reg.d[b])];
|
auto tex = TexMan[*(FTextureID*)&(reg.d[b])];
|
||||||
reg.s[a] = tex == nullptr ? "(null)" : tex->Name.GetChars();
|
reg.s[a] = tex == nullptr ? "(null)" : tex->GetName().GetChars();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2372,7 +2372,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, ReceivedWeapon, ReceivedWeapon)
|
||||||
static int GetMugshot(DBaseStatusBar *self, int accuracy, int stateflags, const FString &def_face)
|
static int GetMugshot(DBaseStatusBar *self, int accuracy, int stateflags, const FString &def_face)
|
||||||
{
|
{
|
||||||
auto tex = self->mugshot.GetFace(self->CPlayer, def_face, accuracy, (FMugShot::StateFlags)stateflags);
|
auto tex = self->mugshot.GetFace(self->CPlayer, def_face, accuracy, (FMugShot::StateFlags)stateflags);
|
||||||
return (tex ? tex->id.GetIndex() : -1);
|
return (tex ? tex->GetID().GetIndex() : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetMugshot, GetMugshot)
|
DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetMugshot, GetMugshot)
|
||||||
|
|
|
@ -107,7 +107,7 @@ namespace swrenderer
|
||||||
std::unique_lock<std::mutex> lock(loadmutex);
|
std::unique_lock<std::mutex> lock(loadmutex);
|
||||||
|
|
||||||
texture->GetPixels(style);
|
texture->GetPixels(style);
|
||||||
const FTexture::Span *spans;
|
const FSoftwareTextureSpan *spans;
|
||||||
texture->GetColumn(style, 0, &spans);
|
texture->GetColumn(style, 0, &spans);
|
||||||
if (Viewport->RenderTarget->IsBgra())
|
if (Viewport->RenderTarget->IsBgra())
|
||||||
{
|
{
|
||||||
|
|
|
@ -88,7 +88,7 @@ void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache)
|
||||||
{
|
{
|
||||||
if (cache & FTextureManager::HIT_Columnmode)
|
if (cache & FTextureManager::HIT_Columnmode)
|
||||||
{
|
{
|
||||||
const FTexture::Span *spanp;
|
const FSoftwareTextureSpan *spanp;
|
||||||
if (isbgra)
|
if (isbgra)
|
||||||
tex->GetColumnBgra(0, &spanp);
|
tex->GetColumnBgra(0, &spanp);
|
||||||
else
|
else
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace swrenderer
|
||||||
fixed_t xscale = 0;
|
fixed_t xscale = 0;
|
||||||
float yscale = 0.0f;
|
float yscale = 0.0f;
|
||||||
|
|
||||||
FTexture *pic = nullptr;
|
FSoftwareTexture *pic = nullptr;
|
||||||
|
|
||||||
fixed_t xiscale = 0;
|
fixed_t xiscale = 0;
|
||||||
fixed_t startfrac = 0;
|
fixed_t startfrac = 0;
|
||||||
|
|
|
@ -62,14 +62,14 @@ namespace swrenderer
|
||||||
dc_iscale = iscale;
|
dc_iscale = iscale;
|
||||||
dc_textureheight = tex->GetHeight();
|
dc_textureheight = tex->GetHeight();
|
||||||
|
|
||||||
const FTexture::Span *span;
|
const FSoftwareTextureSpan *span;
|
||||||
const uint8_t *column;
|
const uint8_t *column;
|
||||||
if (viewport->RenderTarget->IsBgra() && !drawer_needs_pal_input)
|
if (viewport->RenderTarget->IsBgra() && !drawer_needs_pal_input)
|
||||||
column = (const uint8_t *)tex->GetColumnBgra(col >> FRACBITS, &span);
|
column = (const uint8_t *)tex->GetColumnBgra(col >> FRACBITS, &span);
|
||||||
else
|
else
|
||||||
column = tex->GetColumn(style, col >> FRACBITS, &span);
|
column = tex->GetColumn(style, col >> FRACBITS, &span);
|
||||||
|
|
||||||
FTexture::Span unmaskedSpan[2];
|
FSoftwareTextureSpan unmaskedSpan[2];
|
||||||
if (unmasked)
|
if (unmasked)
|
||||||
{
|
{
|
||||||
span = unmaskedSpan;
|
span = unmaskedSpan;
|
||||||
|
@ -192,9 +192,9 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the posts we need to draw
|
// Grab the posts we need to draw
|
||||||
const FTexture::Span *span;
|
const FSoftwareTextureSpan *span;
|
||||||
tex->GetColumnBgra(col >> FRACBITS, &span);
|
tex->GetColumnBgra(col >> FRACBITS, &span);
|
||||||
FTexture::Span unmaskedSpan[2];
|
FSoftwareTextureSpan unmaskedSpan[2];
|
||||||
if (unmasked)
|
if (unmasked)
|
||||||
{
|
{
|
||||||
span = unmaskedSpan;
|
span = unmaskedSpan;
|
||||||
|
|
|
@ -224,7 +224,7 @@ void FTextureManager::InitAnimated (void)
|
||||||
(anim_p[21] << 16) | (anim_p[22] << 24);
|
(anim_p[21] << 16) | (anim_p[22] << 24);
|
||||||
|
|
||||||
// SMMU-style swirly hack? Don't apply on already-warping texture
|
// SMMU-style swirly hack? Don't apply on already-warping texture
|
||||||
if (animspeed > 65535 && tex1 != NULL && !tex1->bWarped)
|
if (animspeed > 65535 && tex1 != NULL && !tex1->isWarped())
|
||||||
{
|
{
|
||||||
FTexture *warper = new FWarpTexture (tex1, 2);
|
FTexture *warper = new FWarpTexture (tex1, 2);
|
||||||
ReplaceTexture (pic1, warper, false);
|
ReplaceTexture (pic1, warper, false);
|
||||||
|
@ -622,7 +622,7 @@ void FTextureManager::ParseWarp(FScanner &sc)
|
||||||
|
|
||||||
|
|
||||||
// don't warp a texture more than once
|
// don't warp a texture more than once
|
||||||
if (!warper->bWarped)
|
if (!warper->isWarped())
|
||||||
{
|
{
|
||||||
warper = new FWarpTexture (warper, type2? 2:1);
|
warper = new FWarpTexture (warper, type2? 2:1);
|
||||||
ReplaceTexture (picnum, warper, false);
|
ReplaceTexture (picnum, warper, false);
|
||||||
|
|
|
@ -61,7 +61,7 @@ FCanvasTexture::~FCanvasTexture ()
|
||||||
Unload ();
|
Unload ();
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t *FCanvasTexture::GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out)
|
const uint8_t *FCanvasTexture::GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out)
|
||||||
{
|
{
|
||||||
bNeedsUpdate = true;
|
bNeedsUpdate = true;
|
||||||
if (Canvas == NULL)
|
if (Canvas == NULL)
|
||||||
|
|
|
@ -164,7 +164,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint8_t *Pixels;
|
uint8_t *Pixels;
|
||||||
Span **Spans;
|
FSoftwareTextureSpan **Spans;
|
||||||
int DefinitionLump;
|
int DefinitionLump;
|
||||||
|
|
||||||
struct TexPart
|
struct TexPart
|
||||||
|
@ -199,7 +199,7 @@ protected:
|
||||||
|
|
||||||
// The getters must optionally redirect if it's a simple one-patch texture.
|
// The getters must optionally redirect if it's a simple one-patch texture.
|
||||||
const uint8_t *GetPixels(FRenderStyle style) override { return bRedirect ? Parts->Texture->GetPixels(style) : FWorldTexture::GetPixels(style); }
|
const uint8_t *GetPixels(FRenderStyle style) override { return bRedirect ? Parts->Texture->GetPixels(style) : FWorldTexture::GetPixels(style); }
|
||||||
const uint8_t *GetColumn(FRenderStyle style, unsigned int col, const Span **out) override
|
const uint8_t *GetColumn(FRenderStyle style, unsigned int col, const FSoftwareTextureSpan **out) override
|
||||||
{ return bRedirect ? Parts->Texture->GetColumn(style, col, out) : FWorldTexture::GetColumn(style, col, out); }
|
{ return bRedirect ? Parts->Texture->GetColumn(style, col, out) : FWorldTexture::GetColumn(style, col, out); }
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ void FWorldTexture::Unload ()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
const uint8_t *FWorldTexture::GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out)
|
const uint8_t *FWorldTexture::GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out)
|
||||||
{
|
{
|
||||||
int index = !!(style.Flags & STYLEF_RedIsAlpha);
|
int index = !!(style.Flags & STYLEF_RedIsAlpha);
|
||||||
GetPixels(style);
|
GetPixels(style);
|
||||||
|
|
|
@ -33,7 +33,8 @@
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
FSkyBox::FSkyBox()
|
FSkyBox::FSkyBox(const char *name)
|
||||||
|
: FTexture(name)
|
||||||
{
|
{
|
||||||
faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5]=NULL;
|
faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5]=NULL;
|
||||||
UseType = ETextureType::Override;
|
UseType = ETextureType::Override;
|
||||||
|
@ -58,7 +59,7 @@ FSkyBox::~FSkyBox()
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
const uint8_t *FSkyBox::GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out)
|
const uint8_t *FSkyBox::GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out)
|
||||||
{
|
{
|
||||||
if (faces[0]) return faces[0]->GetColumn(style, column, spans_out);
|
if (faces[0]) return faces[0]->GetColumn(style, column, spans_out);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -15,9 +15,9 @@ public:
|
||||||
FTexture * faces[6];
|
FTexture * faces[6];
|
||||||
bool fliptop;
|
bool fliptop;
|
||||||
|
|
||||||
FSkyBox();
|
FSkyBox(const char *name = nullptr);
|
||||||
~FSkyBox();
|
~FSkyBox();
|
||||||
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out);
|
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out);
|
||||||
const uint8_t *GetPixels (FRenderStyle style);
|
const uint8_t *GetPixels (FRenderStyle style);
|
||||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf);
|
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf);
|
||||||
bool UseBasePalette();
|
bool UseBasePalette();
|
||||||
|
@ -27,9 +27,7 @@ public:
|
||||||
{
|
{
|
||||||
if (faces[0])
|
if (faces[0])
|
||||||
{
|
{
|
||||||
Width=faces[0]->GetWidth();
|
CopySize(faces[0]);
|
||||||
Height=faces[0]->GetHeight();
|
|
||||||
CalcBitSize();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ void FTexture::Unload()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
const uint32_t *FTexture::GetColumnBgra(unsigned int column, const Span **spans_out)
|
const uint32_t *FTexture::GetColumnBgra(unsigned int column, const FSoftwareTextureSpan **spans_out)
|
||||||
{
|
{
|
||||||
const uint32_t *pixels = GetPixelsBgra();
|
const uint32_t *pixels = GetPixelsBgra();
|
||||||
if (pixels == nullptr) return nullptr;
|
if (pixels == nullptr) return nullptr;
|
||||||
|
@ -327,14 +327,14 @@ void FTexture::CalcBitSize ()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture::Span **FTexture::CreateSpans (const uint8_t *pixels) const
|
FSoftwareTextureSpan **FTexture::CreateSpans (const uint8_t *pixels) const
|
||||||
{
|
{
|
||||||
Span **spans, *span;
|
FSoftwareTextureSpan **spans, *span;
|
||||||
|
|
||||||
if (!bMasked)
|
if (!bMasked)
|
||||||
{ // Texture does not have holes, so it can use a simpler span structure
|
{ // Texture does not have holes, so it can use a simpler span structure
|
||||||
spans = (Span **)M_Malloc (sizeof(Span*)*Width + sizeof(Span)*2);
|
spans = (FSoftwareTextureSpan **)M_Malloc (sizeof(FSoftwareTextureSpan*)*Width + sizeof(FSoftwareTextureSpan)*2);
|
||||||
span = (Span *)&spans[Width];
|
span = (FSoftwareTextureSpan *)&spans[Width];
|
||||||
for (int x = 0; x < Width; ++x)
|
for (int x = 0; x < Width; ++x)
|
||||||
{
|
{
|
||||||
spans[x] = span;
|
spans[x] = span;
|
||||||
|
@ -378,10 +378,10 @@ FTexture::Span **FTexture::CreateSpans (const uint8_t *pixels) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate space for the spans
|
// Allocate space for the spans
|
||||||
spans = (Span **)M_Malloc (sizeof(Span*)*numcols + sizeof(Span)*numspans);
|
spans = (FSoftwareTextureSpan **)M_Malloc (sizeof(FSoftwareTextureSpan*)*numcols + sizeof(FSoftwareTextureSpan)*numspans);
|
||||||
|
|
||||||
// Fill in the spans
|
// Fill in the spans
|
||||||
for (x = 0, span = (Span *)&spans[numcols], data_p = pixels; x < numcols; ++x)
|
for (x = 0, span = (FSoftwareTextureSpan *)&spans[numcols], data_p = pixels; x < numcols; ++x)
|
||||||
{
|
{
|
||||||
newspan = true;
|
newspan = true;
|
||||||
spans[x] = span;
|
spans[x] = span;
|
||||||
|
@ -421,7 +421,7 @@ FTexture::Span **FTexture::CreateSpans (const uint8_t *pixels) const
|
||||||
return spans;
|
return spans;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FTexture::FreeSpans (Span **spans) const
|
void FTexture::FreeSpans (FSoftwareTextureSpan **spans) const
|
||||||
{
|
{
|
||||||
M_Free (spans);
|
M_Free (spans);
|
||||||
}
|
}
|
||||||
|
@ -996,29 +996,22 @@ PalEntry FTexture::GetSkyCapColor(bool bottom)
|
||||||
|
|
||||||
int FTexture::CheckRealHeight()
|
int FTexture::CheckRealHeight()
|
||||||
{
|
{
|
||||||
const FTexture::Span *span;
|
auto pixels = GetPixels(DefaultRenderStyle());
|
||||||
int maxy = 0, miny = GetHeight();
|
|
||||||
|
|
||||||
for (int i = 0; i < GetWidth(); ++i)
|
for(int h = GetHeight()-1; h>= 0; h--)
|
||||||
{
|
{
|
||||||
GetColumn(DefaultRenderStyle(), i, &span);
|
for(int w = 0; w < GetWidth(); w++)
|
||||||
while (span->Length != 0)
|
|
||||||
{
|
{
|
||||||
if (span->TopOffset < miny)
|
if (pixels[h + w * GetHeight()] != 0)
|
||||||
{
|
{
|
||||||
miny = span->TopOffset;
|
|
||||||
}
|
|
||||||
if (span->TopOffset + span->Length > maxy)
|
|
||||||
{
|
|
||||||
maxy = span->TopOffset + span->Length;
|
|
||||||
}
|
|
||||||
span++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Scale maxy before returning it
|
// Scale maxy before returning it
|
||||||
maxy = int((maxy * 2) / Scale.Y);
|
h = int((h * 2) / Scale.Y);
|
||||||
maxy = (maxy >> 1) + (maxy & 1);
|
h = (h >> 1) + (h & 1);
|
||||||
return maxy;
|
return h;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1461,7 +1454,7 @@ void FTexture::SetSpriteAdjust()
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
const uint8_t *FTexture::GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out)
|
const uint8_t *FTexture::GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out)
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1511,43 +1504,6 @@ FWrapperTexture::FWrapperTexture(int w, int h, int bits)
|
||||||
SystemTexture[0] = screen->CreateHardwareTexture(this);
|
SystemTexture[0] = screen->CreateHardwareTexture(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// Debug stuff
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
|
||||||
// Prints the spans generated for a texture. Only needed for debugging.
|
|
||||||
CCMD (printspans)
|
|
||||||
{
|
|
||||||
if (argv.argc() != 2)
|
|
||||||
return;
|
|
||||||
|
|
||||||
FTextureID picnum = TexMan.CheckForTexture (argv[1], ETextureType::Any);
|
|
||||||
if (!picnum.Exists())
|
|
||||||
{
|
|
||||||
Printf ("Unknown texture %s\n", argv[1]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
FTexture *tex = TexMan[picnum];
|
|
||||||
for (int x = 0; x < tex->GetWidth(); ++x)
|
|
||||||
{
|
|
||||||
const FTexture::Span *spans;
|
|
||||||
Printf ("%4d:", x);
|
|
||||||
tex->GetColumn(DefaultRenderStyle(), x, &spans);
|
|
||||||
while (spans->Length != 0)
|
|
||||||
{
|
|
||||||
Printf (" (%4d,%4d)", spans->TopOffset, spans->TopOffset+spans->Length-1);
|
|
||||||
spans++;
|
|
||||||
}
|
|
||||||
Printf ("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Coordinate helper.
|
// Coordinate helper.
|
||||||
|
|
|
@ -211,10 +211,40 @@ enum FTextureFormat : uint32_t
|
||||||
TEX_Count
|
TEX_Count
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FSoftwareTexture;
|
||||||
|
class FGLRenderState;
|
||||||
|
|
||||||
|
struct FSoftwareTextureSpan
|
||||||
|
{
|
||||||
|
uint16_t TopOffset;
|
||||||
|
uint16_t Length; // A length of 0 terminates this column
|
||||||
|
};
|
||||||
|
|
||||||
|
struct spriteframewithrotate;
|
||||||
|
class FSerializer;
|
||||||
|
|
||||||
// Base texture class
|
// Base texture class
|
||||||
class FTexture
|
class FTexture
|
||||||
{
|
{
|
||||||
|
// This is initialization code that is allowed to have full access.
|
||||||
|
friend void R_InitSpriteDefs ();
|
||||||
|
friend void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe);
|
||||||
|
friend class GLDefsParser;
|
||||||
|
|
||||||
|
// The serializer also needs access to more specific info that shouldn't be accessible through the interface.
|
||||||
|
friend FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTextureID *defval);
|
||||||
|
|
||||||
|
// For now only give access to classes which cannot be reworked yet. None of these should remain here when all is done.
|
||||||
|
friend class FSoftwareTexture;
|
||||||
|
friend class FWarpTexture;
|
||||||
|
friend class FMaterial;
|
||||||
|
friend class FGLRenderState; // For now this needs access to some fields in ApplyMaterial. This should be rerouted through the Material class
|
||||||
|
friend struct FTexCoordInfo;
|
||||||
|
friend class FHardwareTexture;
|
||||||
|
friend class FMultiPatchTexture;
|
||||||
|
friend class FSkyBox;
|
||||||
|
friend void RecordTextureColors (FTexture *pic, uint8_t *usedcolors);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static FTexture *CreateTexture(const char *name, int lumpnum, ETextureType usetype);
|
static FTexture *CreateTexture(const char *name, int lumpnum, ETextureType usetype);
|
||||||
|
@ -223,6 +253,61 @@ public:
|
||||||
void AddAutoMaterials();
|
void AddAutoMaterials();
|
||||||
unsigned char *CreateUpsampledTextureBuffer(unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha);
|
unsigned char *CreateUpsampledTextureBuffer(unsigned char *inputBuffer, const int inWidth, const int inHeight, int &outWidth, int &outHeight, bool hasAlpha);
|
||||||
|
|
||||||
|
// These should only be used in places where the texture scaling must be ignored and absolutely nowhere else!
|
||||||
|
// Preferably all code depending on the physical texture size should be rewritten, unless it is part of the software rasterizer.
|
||||||
|
//int GetPixelWidth() { return GetWidth(); }
|
||||||
|
//int GetPixelHeight() { return GetHeight(); }
|
||||||
|
|
||||||
|
// These are mainly meant for 2D code which only needs logical information about the texture to position it properly.
|
||||||
|
int GetDisplayWidth() { return GetScaledWidth(); }
|
||||||
|
int GetDisplayHeight() { return GetScaledHeight(); }
|
||||||
|
double GetDisplayWidthDouble() { return GetScaledWidthDouble(); }
|
||||||
|
double GetDisplayHeightDouble() { return GetScaledHeightDouble(); }
|
||||||
|
int GetDisplayLeftOffset() { return GetScaledLeftOffset(0); }
|
||||||
|
int GetDisplayTopOffset() { return GetScaledTopOffset(0); }
|
||||||
|
double GetDisplayLeftOffsetDouble() { return GetScaledLeftOffsetDouble(0); }
|
||||||
|
double GetDisplayTopOffsetDouble() { return GetScaledTopOffsetDouble(0); }
|
||||||
|
|
||||||
|
|
||||||
|
bool isValid() const { return UseType != ETextureType::Null; }
|
||||||
|
bool isSWCanvas() const { return UseType == ETextureType::SWCanvas; }
|
||||||
|
bool isSkybox() const { return bSkybox; }
|
||||||
|
bool isFullbrightDisabled() const { return bDisableFullbright; }
|
||||||
|
bool isHardwareCanvas() const { return bHasCanvas; } // There's two here so that this can deal with software canvases in the hardware renderer later.
|
||||||
|
bool isCanvas() const { return bHasCanvas; }
|
||||||
|
int isWarped() const { return bWarped; }
|
||||||
|
int GetRotations() const { return Rotations; }
|
||||||
|
void SetRotations(int rot) { Rotations = int16_t(rot); }
|
||||||
|
|
||||||
|
const FString &GetName() const { return Name; }
|
||||||
|
bool allowNoDecals() const { return bNoDecals; }
|
||||||
|
bool isScaled() const { return Scale.X != 1 || Scale.Y != 1; }
|
||||||
|
int GetSkyOffset() const { return SkyOffset; }
|
||||||
|
FTextureID GetID() const { return id; }
|
||||||
|
PalEntry GetSkyCapColor(bool bottom);
|
||||||
|
virtual FTexture *GetRawTexture(); // for FMultiPatchTexture to override
|
||||||
|
void GetGlowColor(float *data);
|
||||||
|
bool isGlowing() const { return bGlowing; }
|
||||||
|
bool isAutoGlowing() const { return bAutoGlowing; }
|
||||||
|
int GetGlowHeight() const { return GlowHeight; }
|
||||||
|
bool isFullbright() const { return bFullbright; }
|
||||||
|
void CreateDefaultBrightmap();
|
||||||
|
bool FindHoles(const unsigned char * buffer, int w, int h);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static void FlipSquareBlock (uint8_t *block, int x, int y);
|
||||||
|
static void FlipSquareBlockBgra (uint32_t *block, int x, int y);
|
||||||
|
static void FlipSquareBlockRemap (uint8_t *block, int x, int y, const uint8_t *remap);
|
||||||
|
static void FlipNonSquareBlock (uint8_t *blockto, const uint8_t *blockfrom, int x, int y, int srcpitch);
|
||||||
|
static void FlipNonSquareBlockBgra (uint32_t *blockto, const uint32_t *blockfrom, int x, int y, int srcpitch);
|
||||||
|
static void FlipNonSquareBlockRemap (uint8_t *blockto, const uint8_t *blockfrom, int x, int y, int srcpitch, const uint8_t *remap);
|
||||||
|
static bool SmoothEdges(unsigned char * buffer,int w, int h);
|
||||||
|
static PalEntry averageColor(const uint32_t *data, int size, int maxout);
|
||||||
|
|
||||||
|
|
||||||
|
FSoftwareTexture *GetSoftwareTexture();
|
||||||
|
|
||||||
|
protected:
|
||||||
//int16_t LeftOffset, TopOffset;
|
//int16_t LeftOffset, TopOffset;
|
||||||
|
|
||||||
uint8_t WidthBits, HeightBits;
|
uint8_t WidthBits, HeightBits;
|
||||||
|
@ -234,6 +319,7 @@ public:
|
||||||
|
|
||||||
FMaterial *Material[2] = { nullptr, nullptr };
|
FMaterial *Material[2] = { nullptr, nullptr };
|
||||||
IHardwareTexture *SystemTexture[2] = { nullptr, nullptr };
|
IHardwareTexture *SystemTexture[2] = { nullptr, nullptr };
|
||||||
|
FSoftwareTexture *SoftwareTexture;
|
||||||
|
|
||||||
// None of the following pointers are owned by this texture, they are all controlled by the texture manager.
|
// None of the following pointers are owned by this texture, they are all controlled by the texture manager.
|
||||||
|
|
||||||
|
@ -292,17 +378,11 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct Span
|
|
||||||
{
|
|
||||||
uint16_t TopOffset;
|
|
||||||
uint16_t Length; // A length of 0 terminates this column
|
|
||||||
};
|
|
||||||
|
|
||||||
// Returns a single column of the texture
|
// Returns a single column of the texture
|
||||||
virtual const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out);
|
virtual const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out);
|
||||||
|
|
||||||
// Returns a single column of the texture, in BGRA8 format
|
// Returns a single column of the texture, in BGRA8 format
|
||||||
virtual const uint32_t *GetColumnBgra(unsigned int column, const Span **spans_out);
|
virtual const uint32_t *GetColumnBgra(unsigned int column, const FSoftwareTextureSpan **spans_out);
|
||||||
|
|
||||||
// Returns the whole texture, stored in column-major order
|
// Returns the whole texture, stored in column-major order
|
||||||
virtual const uint8_t *GetPixels(FRenderStyle style);
|
virtual const uint8_t *GetPixels(FRenderStyle style);
|
||||||
|
@ -318,7 +398,6 @@ public:
|
||||||
virtual bool UseBasePalette();
|
virtual bool UseBasePalette();
|
||||||
virtual int GetSourceLump() { return SourceLump; }
|
virtual int GetSourceLump() { return SourceLump; }
|
||||||
virtual FTexture *GetRedirect();
|
virtual FTexture *GetRedirect();
|
||||||
virtual FTexture *GetRawTexture(); // for FMultiPatchTexture to override
|
|
||||||
|
|
||||||
virtual void Unload ();
|
virtual void Unload ();
|
||||||
|
|
||||||
|
@ -392,8 +471,6 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetScaledSize(int fitwidth, int fitheight);
|
void SetScaledSize(int fitwidth, int fitheight);
|
||||||
PalEntry GetSkyCapColor(bool bottom);
|
|
||||||
static PalEntry averageColor(const uint32_t *data, int size, int maxout);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint16_t Width, Height, WidthMask;
|
uint16_t Width, Height, WidthMask;
|
||||||
|
@ -448,8 +525,8 @@ protected:
|
||||||
|
|
||||||
FTexture (const char *name = NULL, int lumpnum = -1);
|
FTexture (const char *name = NULL, int lumpnum = -1);
|
||||||
|
|
||||||
Span **CreateSpans (const uint8_t *pixels) const;
|
FSoftwareTextureSpan **CreateSpans (const uint8_t *pixels) const;
|
||||||
void FreeSpans (Span **spans) const;
|
void FreeSpans (FSoftwareTextureSpan **spans) const;
|
||||||
void CalcBitSize ();
|
void CalcBitSize ();
|
||||||
void CopyInfo(FTexture *other)
|
void CopyInfo(FTexture *other)
|
||||||
{
|
{
|
||||||
|
@ -481,21 +558,7 @@ private:
|
||||||
PalEntry CeilingSkyColor;
|
PalEntry CeilingSkyColor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void FlipSquareBlock (uint8_t *block, int x, int y);
|
|
||||||
static void FlipSquareBlockBgra (uint32_t *block, int x, int y);
|
|
||||||
static void FlipSquareBlockRemap (uint8_t *block, int x, int y, const uint8_t *remap);
|
|
||||||
static void FlipNonSquareBlock (uint8_t *blockto, const uint8_t *blockfrom, int x, int y, int srcpitch);
|
|
||||||
static void FlipNonSquareBlockBgra (uint32_t *blockto, const uint32_t *blockfrom, int x, int y, int srcpitch);
|
|
||||||
static void FlipNonSquareBlockRemap (uint8_t *blockto, const uint8_t *blockfrom, int x, int y, int srcpitch, const uint8_t *remap);
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
void GetGlowColor(float *data);
|
|
||||||
bool isGlowing() { return bGlowing; }
|
|
||||||
bool isFullbright() { return bFullbright; }
|
|
||||||
void CreateDefaultBrightmap();
|
|
||||||
bool FindHoles(const unsigned char * buffer, int w, int h);
|
|
||||||
static bool SmoothEdges(unsigned char * buffer,int w, int h);
|
|
||||||
void CheckTrans(unsigned char * buffer, int size, int trans);
|
void CheckTrans(unsigned char * buffer, int size, int trans);
|
||||||
bool ProcessData(unsigned char * buffer, int w, int h, bool ispatch);
|
bool ProcessData(unsigned char * buffer, int w, int h, bool ispatch);
|
||||||
int CheckRealHeight();
|
int CheckRealHeight();
|
||||||
|
@ -504,6 +567,100 @@ public:
|
||||||
friend class FTextureManager;
|
friend class FTextureManager;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// For now this is just a minimal wrapper around FTexture. Once the software renderer no longer accesses FTexture directly, it is time for cleaning up.
|
||||||
|
class FSoftwareTexture
|
||||||
|
{
|
||||||
|
FTexture *mTexture;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
FSoftwareTexture(FTexture *tex)
|
||||||
|
{
|
||||||
|
mTexture = tex;
|
||||||
|
}
|
||||||
|
|
||||||
|
FTexture *GetTexture() const
|
||||||
|
{
|
||||||
|
return mTexture;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The feature from hell... :(
|
||||||
|
bool useWorldPanning() const
|
||||||
|
{
|
||||||
|
return mTexture->bWorldPanning;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UseBasePalette() const { return mTexture->UseBasePalette(); }
|
||||||
|
int GetSkyOffset() const { return mTexture->GetSkyOffset(); }
|
||||||
|
PalEntry GetSkyCapColor(bool bottom) const { return mTexture->GetSkyCapColor(bottom); }
|
||||||
|
|
||||||
|
int GetWidth () { return mTexture->GetWidth(); }
|
||||||
|
int GetHeight () { return mTexture->GetHeight(); }
|
||||||
|
|
||||||
|
int GetScaledWidth () { return mTexture->GetScaledWidth(); }
|
||||||
|
int GetScaledHeight () { return mTexture->GetScaledHeight(); }
|
||||||
|
double GetScaledWidthDouble () { return mTexture->GetScaledWidthDouble(); }
|
||||||
|
double GetScaledHeightDouble () { return mTexture->GetScaledHeightDouble(); }
|
||||||
|
double GetScaleY() const { return mTexture->GetScaleY(); }
|
||||||
|
|
||||||
|
// Now with improved offset adjustment.
|
||||||
|
int GetLeftOffset(int adjusted) { return mTexture->GetLeftOffset(adjusted); }
|
||||||
|
int GetTopOffset(int adjusted) { return mTexture->GetTopOffset(adjusted); }
|
||||||
|
int GetScaledLeftOffset (int adjusted) { return mTexture->GetScaledLeftOffset(adjusted); }
|
||||||
|
int GetScaledTopOffset (int adjusted) { return mTexture->GetScaledTopOffset(adjusted); }
|
||||||
|
double GetScaledLeftOffsetDouble(int adjusted) { return mTexture->GetScaledLeftOffsetDouble(adjusted); }
|
||||||
|
double GetScaledTopOffsetDouble(int adjusted) { return mTexture->GetScaledTopOffsetDouble(adjusted); }
|
||||||
|
|
||||||
|
// Interfaces for the different renderers. Everything that needs to check renderer-dependent offsets
|
||||||
|
// should use these, so that if changes are needed, this is the only place to edit.
|
||||||
|
|
||||||
|
// For the original software renderer
|
||||||
|
int GetLeftOffsetSW() { return GetLeftOffset(r_spriteadjustSW); }
|
||||||
|
int GetTopOffsetSW() { return GetTopOffset(r_spriteadjustSW); }
|
||||||
|
int GetScaledLeftOffsetSW() { return GetScaledLeftOffset(r_spriteadjustSW); }
|
||||||
|
int GetScaledTopOffsetSW() { return GetScaledTopOffset(r_spriteadjustSW); }
|
||||||
|
|
||||||
|
// For the softpoly renderer, in case it wants adjustment
|
||||||
|
int GetLeftOffsetPo() { return GetLeftOffset(r_spriteadjustSW); }
|
||||||
|
int GetTopOffsetPo() { return GetTopOffset(r_spriteadjustSW); }
|
||||||
|
int GetScaledLeftOffsetPo() { return GetScaledLeftOffset(r_spriteadjustSW); }
|
||||||
|
int GetScaledTopOffsetPo() { return GetScaledTopOffset(r_spriteadjustSW); }
|
||||||
|
|
||||||
|
DVector2 GetScale() const { return mTexture->Scale; }
|
||||||
|
|
||||||
|
// Returns a single column of the texture
|
||||||
|
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out)
|
||||||
|
{
|
||||||
|
return mTexture->GetColumn(style, column, spans_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a single column of the texture, in BGRA8 format
|
||||||
|
const uint32_t *GetColumnBgra(unsigned int column, const FSoftwareTextureSpan **spans_out)
|
||||||
|
{
|
||||||
|
return mTexture->GetColumnBgra(column, spans_out);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the whole texture, stored in column-major order
|
||||||
|
const uint8_t *GetPixels(FRenderStyle style)
|
||||||
|
{
|
||||||
|
return mTexture->GetPixels(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the whole texture, stored in column-major order, in BGRA8 format
|
||||||
|
const uint32_t *GetPixelsBgra()
|
||||||
|
{
|
||||||
|
return mTexture->GetPixelsBgra();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline FSoftwareTexture *FTexture::GetSoftwareTexture()
|
||||||
|
{
|
||||||
|
if (!SoftwareTexture) SoftwareTexture = new FSoftwareTexture(this);
|
||||||
|
return SoftwareTexture;
|
||||||
|
}
|
||||||
|
|
||||||
class FxAddSub;
|
class FxAddSub;
|
||||||
// Texture manager
|
// Texture manager
|
||||||
class FTextureManager
|
class FTextureManager
|
||||||
|
@ -703,13 +860,13 @@ class FWorldTexture : public FTexture
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
uint8_t *Pixeldata[2] = { nullptr, nullptr };
|
uint8_t *Pixeldata[2] = { nullptr, nullptr };
|
||||||
Span **Spandata[2] = { nullptr, nullptr };
|
FSoftwareTextureSpan **Spandata[2] = { nullptr, nullptr };
|
||||||
uint8_t PixelsAreStatic = 0; // can be set by subclasses which provide static pixel buffers.
|
uint8_t PixelsAreStatic = 0; // can be set by subclasses which provide static pixel buffers.
|
||||||
|
|
||||||
FWorldTexture(const char *name = nullptr, int lumpnum = -1);
|
FWorldTexture(const char *name = nullptr, int lumpnum = -1);
|
||||||
~FWorldTexture();
|
~FWorldTexture();
|
||||||
|
|
||||||
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out) override;
|
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out) override;
|
||||||
const uint8_t *GetPixels(FRenderStyle style) override;
|
const uint8_t *GetPixels(FRenderStyle style) override;
|
||||||
void Unload() override;
|
void Unload() override;
|
||||||
virtual uint8_t *MakeTexture(FRenderStyle style) = 0;
|
virtual uint8_t *MakeTexture(FRenderStyle style) = 0;
|
||||||
|
@ -763,7 +920,7 @@ public:
|
||||||
FCanvasTexture (const char *name, int width, int height);
|
FCanvasTexture (const char *name, int width, int height);
|
||||||
~FCanvasTexture ();
|
~FCanvasTexture ();
|
||||||
|
|
||||||
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out);
|
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out);
|
||||||
const uint8_t *GetPixels (FRenderStyle style);
|
const uint8_t *GetPixels (FRenderStyle style);
|
||||||
const uint32_t *GetPixelsBgra() override;
|
const uint32_t *GetPixelsBgra() override;
|
||||||
void Unload ();
|
void Unload ();
|
||||||
|
@ -782,7 +939,7 @@ protected:
|
||||||
DCanvas *CanvasBgra = nullptr;
|
DCanvas *CanvasBgra = nullptr;
|
||||||
uint8_t *Pixels = nullptr;
|
uint8_t *Pixels = nullptr;
|
||||||
uint32_t *PixelsBgra = nullptr;
|
uint32_t *PixelsBgra = nullptr;
|
||||||
Span DummySpans[2];
|
FSoftwareTextureSpan DummySpans[2];
|
||||||
bool bNeedsUpdate = true;
|
bool bNeedsUpdate = true;
|
||||||
bool bDidUpdate = false;
|
bool bDidUpdate = false;
|
||||||
bool bPixelsAllocated = false;
|
bool bPixelsAllocated = false;
|
||||||
|
@ -799,6 +956,10 @@ class FWrapperTexture : public FTexture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FWrapperTexture(int w, int h, int bits = 1);
|
FWrapperTexture(int w, int h, int bits = 1);
|
||||||
|
IHardwareTexture *GetSystemTexture(int slot)
|
||||||
|
{
|
||||||
|
return SystemTexture[slot];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FTextureManager TexMan;
|
extern FTextureManager TexMan;
|
||||||
|
|
|
@ -125,7 +125,6 @@ void F2DDrawer::AddIndices(int firstvert, int count, ...)
|
||||||
|
|
||||||
bool F2DDrawer::SetStyle(FTexture *tex, DrawParms &parms, PalEntry &vertexcolor, RenderCommand &quad)
|
bool F2DDrawer::SetStyle(FTexture *tex, DrawParms &parms, PalEntry &vertexcolor, RenderCommand &quad)
|
||||||
{
|
{
|
||||||
auto fmt = tex->GetFormat();
|
|
||||||
FRenderStyle style = parms.style;
|
FRenderStyle style = parms.style;
|
||||||
float alpha;
|
float alpha;
|
||||||
bool stencilling;
|
bool stencilling;
|
||||||
|
@ -298,12 +297,12 @@ void F2DDrawer::AddTexture(FTexture *img, DrawParms &parms)
|
||||||
dg.mType = DrawTypeTriangles;
|
dg.mType = DrawTypeTriangles;
|
||||||
dg.mVertCount = 4;
|
dg.mVertCount = 4;
|
||||||
dg.mTexture = img;
|
dg.mTexture = img;
|
||||||
if (img->bWarped) dg.mFlags |= DTF_Wrap;
|
if (img->isWarped()) dg.mFlags |= DTF_Wrap;
|
||||||
|
|
||||||
dg.mTranslation = 0;
|
dg.mTranslation = 0;
|
||||||
SetStyle(img, parms, vertexcolor, dg);
|
SetStyle(img, parms, vertexcolor, dg);
|
||||||
|
|
||||||
if (!img->bHasCanvas && parms.remap != nullptr && !parms.remap->Inactive)
|
if (!img->isHardwareCanvas() && parms.remap != nullptr && !parms.remap->Inactive)
|
||||||
{
|
{
|
||||||
dg.mTranslation = parms.remap;
|
dg.mTranslation = parms.remap;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +377,7 @@ void F2DDrawer::AddShape( FTexture *img, DShape2D *shape, DrawParms &parms )
|
||||||
dg.mTranslation = 0;
|
dg.mTranslation = 0;
|
||||||
SetStyle(img, parms, vertexcolor, dg);
|
SetStyle(img, parms, vertexcolor, dg);
|
||||||
|
|
||||||
if (!img->bHasCanvas && parms.remap != nullptr && !parms.remap->Inactive)
|
if (!img->isHardwareCanvas() && parms.remap != nullptr && !parms.remap->Inactive)
|
||||||
dg.mTranslation = parms.remap;
|
dg.mTranslation = parms.remap;
|
||||||
|
|
||||||
double minx = 16383, miny = 16383, maxx = -16384, maxy = -16384;
|
double minx = 16383, miny = 16383, maxx = -16384, maxy = -16384;
|
||||||
|
@ -466,8 +465,8 @@ void F2DDrawer::AddPoly(FTexture *texture, FVector2 *points, int npoints,
|
||||||
float cosrot = (float)cos(rotation.Radians());
|
float cosrot = (float)cos(rotation.Radians());
|
||||||
float sinrot = (float)sin(rotation.Radians());
|
float sinrot = (float)sin(rotation.Radians());
|
||||||
|
|
||||||
float uscale = float(1.f / (texture->GetScaledWidth() * scalex));
|
float uscale = float(1.f / (texture->GetDisplayWidth() * scalex));
|
||||||
float vscale = float(1.f / (texture->GetScaledHeight() * scaley));
|
float vscale = float(1.f / (texture->GetDisplayHeight() * scaley));
|
||||||
float ox = float(originx);
|
float ox = float(originx);
|
||||||
float oy = float(originy);
|
float oy = float(originy);
|
||||||
|
|
||||||
|
@ -529,17 +528,17 @@ void F2DDrawer::AddFlatFill(int left, int top, int right, int bottom, FTexture *
|
||||||
// scaling is not used here.
|
// scaling is not used here.
|
||||||
if (!local_origin)
|
if (!local_origin)
|
||||||
{
|
{
|
||||||
fU1 = float(left) / src->GetWidth();
|
fU1 = float(left) / src->GetDisplayWidth();
|
||||||
fV1 = float(top) / src->GetHeight();
|
fV1 = float(top) / src->GetDisplayHeight();
|
||||||
fU2 = float(right) / src->GetWidth();
|
fU2 = float(right) / src->GetDisplayWidth();
|
||||||
fV2 = float(bottom) / src->GetHeight();
|
fV2 = float(bottom) / src->GetDisplayHeight();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fU1 = 0;
|
fU1 = 0;
|
||||||
fV1 = 0;
|
fV1 = 0;
|
||||||
fU2 = float(right - left) / src->GetWidth();
|
fU2 = float(right - left) / src->GetDisplayWidth();
|
||||||
fV2 = float(bottom - top) / src->GetHeight();
|
fV2 = float(bottom - top) / src->GetDisplayHeight();
|
||||||
}
|
}
|
||||||
dg.mVertIndex = (int)mVertices.Reserve(4);
|
dg.mVertIndex = (int)mVertices.Reserve(4);
|
||||||
auto ptr = &mVertices[dg.mVertIndex];
|
auto ptr = &mVertices[dg.mVertIndex];
|
||||||
|
|
|
@ -312,23 +312,23 @@ bool DFrameBuffer::SetTextureParms(DrawParms *parms, FTexture *img, double xx, d
|
||||||
{
|
{
|
||||||
parms->x = xx;
|
parms->x = xx;
|
||||||
parms->y = yy;
|
parms->y = yy;
|
||||||
parms->texwidth = img->GetScaledWidthDouble();
|
parms->texwidth = img->GetDisplayWidthDouble();
|
||||||
parms->texheight = img->GetScaledHeightDouble();
|
parms->texheight = img->GetDisplayHeightDouble();
|
||||||
if (parms->top == INT_MAX || parms->fortext)
|
if (parms->top == INT_MAX || parms->fortext)
|
||||||
{
|
{
|
||||||
parms->top = img->GetScaledTopOffset(0);
|
parms->top = img->GetDisplayTopOffset();
|
||||||
}
|
}
|
||||||
if (parms->left == INT_MAX || parms->fortext)
|
if (parms->left == INT_MAX || parms->fortext)
|
||||||
{
|
{
|
||||||
parms->left = img->GetScaledLeftOffset(0);
|
parms->left = img->GetDisplayLeftOffset();
|
||||||
}
|
}
|
||||||
if (parms->destwidth == INT_MAX || parms->fortext)
|
if (parms->destwidth == INT_MAX || parms->fortext)
|
||||||
{
|
{
|
||||||
parms->destwidth = img->GetScaledWidthDouble();
|
parms->destwidth = img->GetDisplayWidthDouble();
|
||||||
}
|
}
|
||||||
if (parms->destheight == INT_MAX || parms->fortext)
|
if (parms->destheight == INT_MAX || parms->fortext)
|
||||||
{
|
{
|
||||||
parms->destheight = img->GetScaledHeightDouble();
|
parms->destheight = img->GetDisplayHeightDouble();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (parms->cleanmode)
|
switch (parms->cleanmode)
|
||||||
|
@ -470,7 +470,7 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3
|
||||||
|
|
||||||
if (!fortext)
|
if (!fortext)
|
||||||
{
|
{
|
||||||
if (img == NULL || img->UseType == ETextureType::Null)
|
if (img == NULL || !img->isValid())
|
||||||
{
|
{
|
||||||
ListEnd(tags);
|
ListEnd(tags);
|
||||||
return false;
|
return false;
|
||||||
|
@ -650,8 +650,8 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3
|
||||||
assert(fortext == false);
|
assert(fortext == false);
|
||||||
if (img == NULL) return false;
|
if (img == NULL) return false;
|
||||||
parms->cleanmode = DTA_Fullscreen;
|
parms->cleanmode = DTA_Fullscreen;
|
||||||
parms->virtWidth = img->GetScaledWidthDouble();
|
parms->virtWidth = img->GetDisplayWidthDouble();
|
||||||
parms->virtHeight = img->GetScaledHeightDouble();
|
parms->virtHeight = img->GetDisplayHeightDouble();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -697,19 +697,19 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_SrcX:
|
case DTA_SrcX:
|
||||||
parms->srcx = ListGetDouble(tags) / img->GetScaledWidthDouble();
|
parms->srcx = ListGetDouble(tags) / img->GetDisplayWidthDouble();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_SrcY:
|
case DTA_SrcY:
|
||||||
parms->srcy = ListGetDouble(tags) / img->GetScaledHeightDouble();
|
parms->srcy = ListGetDouble(tags) / img->GetDisplayHeightDouble();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_SrcWidth:
|
case DTA_SrcWidth:
|
||||||
parms->srcwidth = ListGetDouble(tags) / img->GetScaledWidthDouble();
|
parms->srcwidth = ListGetDouble(tags) / img->GetDisplayWidthDouble();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_SrcHeight:
|
case DTA_SrcHeight:
|
||||||
parms->srcheight = ListGetDouble(tags) / img->GetScaledHeightDouble();
|
parms->srcheight = ListGetDouble(tags) / img->GetDisplayHeightDouble();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DTA_TopOffset:
|
case DTA_TopOffset:
|
||||||
|
@ -741,8 +741,8 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3
|
||||||
if (fortext) return false;
|
if (fortext) return false;
|
||||||
if (ListGetInt(tags))
|
if (ListGetInt(tags))
|
||||||
{
|
{
|
||||||
parms->left = img->GetScaledWidthDouble() * 0.5;
|
parms->left = img->GetDisplayWidthDouble() * 0.5;
|
||||||
parms->top = img->GetScaledHeightDouble() * 0.5;
|
parms->top = img->GetDisplayHeightDouble() * 0.5;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -751,8 +751,8 @@ bool DFrameBuffer::ParseDrawTextureTags(FTexture *img, double x, double y, uint3
|
||||||
if (fortext) return false;
|
if (fortext) return false;
|
||||||
if (ListGetInt(tags))
|
if (ListGetInt(tags))
|
||||||
{
|
{
|
||||||
parms->left = img->GetScaledWidthDouble() * 0.5;
|
parms->left = img->GetDisplayWidthDouble() * 0.5;
|
||||||
parms->top = img->GetScaledHeightDouble();
|
parms->top = img->GetDisplayHeightDouble();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1305,15 +1305,15 @@ void DFrameBuffer::DrawFrame (int left, int top, int width, int height)
|
||||||
|
|
||||||
// Draw top and bottom sides.
|
// Draw top and bottom sides.
|
||||||
p = TexMan[border->t];
|
p = TexMan[border->t];
|
||||||
FlatFill(left, top - p->GetHeight(), right, top, p, true);
|
FlatFill(left, top - p->GetDisplayHeight(), right, top, p, true);
|
||||||
p = TexMan[border->b];
|
p = TexMan[border->b];
|
||||||
FlatFill(left, bottom, right, bottom + p->GetHeight(), p, true);
|
FlatFill(left, bottom, right, bottom + p->GetDisplayHeight(), p, true);
|
||||||
|
|
||||||
// Draw left and right sides.
|
// Draw left and right sides.
|
||||||
p = TexMan[border->l];
|
p = TexMan[border->l];
|
||||||
FlatFill(left - p->GetWidth(), top, left, bottom, p, true);
|
FlatFill(left - p->GetDisplayWidth(), top, left, bottom, p, true);
|
||||||
p = TexMan[border->r];
|
p = TexMan[border->r];
|
||||||
FlatFill(right, top, right + p->GetWidth(), bottom, p, true);
|
FlatFill(right, top, right + p->GetDisplayWidth(), bottom, p, true);
|
||||||
|
|
||||||
// Draw beveled corners.
|
// Draw beveled corners.
|
||||||
DrawTexture (TexMan[border->tl], left-offset, top-offset, TAG_DONE);
|
DrawTexture (TexMan[border->tl], left-offset, top-offset, TAG_DONE);
|
||||||
|
|
|
@ -171,7 +171,7 @@ class FFontChar1 : public FTexture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FFontChar1 (FTexture *sourcelump);
|
FFontChar1 (FTexture *sourcelump);
|
||||||
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out);
|
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out);
|
||||||
const uint8_t *GetPixels (FRenderStyle style);
|
const uint8_t *GetPixels (FRenderStyle style);
|
||||||
void SetSourceRemap(const uint8_t *sourceremap);
|
void SetSourceRemap(const uint8_t *sourceremap);
|
||||||
void Unload ();
|
void Unload ();
|
||||||
|
@ -192,7 +192,7 @@ public:
|
||||||
FFontChar2 (int sourcelump, int sourcepos, int width, int height, int leftofs=0, int topofs=0);
|
FFontChar2 (int sourcelump, int sourcepos, int width, int height, int leftofs=0, int topofs=0);
|
||||||
~FFontChar2 ();
|
~FFontChar2 ();
|
||||||
|
|
||||||
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const Span **spans_out);
|
const uint8_t *GetColumn(FRenderStyle style, unsigned int column, const FSoftwareTextureSpan **spans_out);
|
||||||
const uint8_t *GetPixels (FRenderStyle style);
|
const uint8_t *GetPixels (FRenderStyle style);
|
||||||
void SetSourceRemap(const uint8_t *sourceremap);
|
void SetSourceRemap(const uint8_t *sourceremap);
|
||||||
void Unload ();
|
void Unload ();
|
||||||
|
@ -201,7 +201,7 @@ protected:
|
||||||
int SourceLump;
|
int SourceLump;
|
||||||
int SourcePos;
|
int SourcePos;
|
||||||
uint8_t *Pixels;
|
uint8_t *Pixels;
|
||||||
Span **Spans;
|
FSoftwareTextureSpan **Spans;
|
||||||
const uint8_t *SourceRemap;
|
const uint8_t *SourceRemap;
|
||||||
|
|
||||||
void MakeTexture ();
|
void MakeTexture ();
|
||||||
|
@ -533,24 +533,14 @@ void RecordTextureColors (FTexture *pic, uint8_t *usedcolors)
|
||||||
{
|
{
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
for (x = pic->GetWidth() - 1; x >= 0; x--)
|
auto pixels = pic->GetPixels(DefaultRenderStyle());
|
||||||
{
|
auto size = pic->GetWidth() * pic->GetHeight();
|
||||||
const FTexture::Span *spans;
|
|
||||||
const uint8_t *column = pic->GetColumn(DefaultRenderStyle(), x, &spans); // This shouldn't use the spans...
|
|
||||||
|
|
||||||
while (spans->Length != 0)
|
for(x = 0;x < size; x++)
|
||||||
{
|
{
|
||||||
const uint8_t *source = column + spans->TopOffset;
|
usedcolors[pixels[x]]++;
|
||||||
int count = spans->Length;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
usedcolors[*source++] = 1;
|
|
||||||
} while (--count);
|
|
||||||
|
|
||||||
spans++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
pic->Unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -1623,7 +1613,7 @@ void FFontChar1::MakeTexture ()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
const uint8_t *FFontChar1::GetColumn(FRenderStyle, unsigned int column, const Span **spans_out)
|
const uint8_t *FFontChar1::GetColumn(FRenderStyle, unsigned int column, const FSoftwareTextureSpan **spans_out)
|
||||||
{
|
{
|
||||||
if (Pixels == NULL)
|
if (Pixels == NULL)
|
||||||
{
|
{
|
||||||
|
@ -1747,7 +1737,7 @@ const uint8_t *FFontChar2::GetPixels (FRenderStyle)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
const uint8_t *FFontChar2::GetColumn(FRenderStyle, unsigned int column, const Span **spans_out)
|
const uint8_t *FFontChar2::GetColumn(FRenderStyle, unsigned int column, const FSoftwareTextureSpan **spans_out)
|
||||||
{
|
{
|
||||||
if (Pixels == NULL)
|
if (Pixels == NULL)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue