- eliminated all cases of calling DrawTexture with an FTexture.

Everything uses FGameTexture now.
This commit is contained in:
Christoph Oelckers 2020-04-14 01:01:29 +02:00
parent c7db5b932e
commit d9928b51a8
13 changed files with 68 additions and 71 deletions

View file

@ -212,11 +212,12 @@ bool SetTextureParms(F2DDrawer *drawer, DrawParms* parms, FTexture* img, double
void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, const char* string, int tag_first, ...);
void DrawText(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, const char32_t* string, int tag_first, ...);
void DrawChar(F2DDrawer* drawer, FFont* font, int normalcolor, double x, double y, int character, int tag_first, ...);
void DrawTexture(F2DDrawer* drawer, FTexture* img, double x, double y, int tags_first, ...);
template <typename ...Params>
void DrawTexture(F2DDrawer* drawer, FGameTexture* img, double x, double y, int tags_first, Params&&... params)
{
void DrawTexture(F2DDrawer * drawer, FTexture * img, double x, double y, int tags_first, ...);
DrawTexture(drawer, img->GetTexture(), x, y, tags_first, std::forward<Params>(params)...);
}

View file

@ -589,7 +589,7 @@ protected:
//
//==========================================================================
FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
FGameTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
{
if (M_FindPNGChunk(png, MAKE_ID('I','H','D','R')) == 0)
{
@ -608,7 +608,7 @@ FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
// Reject anything that cannot be put into a savegame picture by GZDoom itself.
if (compression != 0 || filter != 0 || interlace > 0 || bitdepth != 8 || (colortype != 2 && colortype != 3)) return nullptr;
else return new FPNGFileTexture (png->File, width, height, colortype);
else return reinterpret_cast<FGameTexture*>(new FPNGFileTexture (png->File, width, height, colortype));
}
//==========================================================================

View file

@ -119,8 +119,8 @@ bool M_ReadIDAT (FileReader &file, uint8_t *buffer, int width, int height, int p
uint8_t bitdepth, uint8_t colortype, uint8_t interlace, unsigned int idatlen);
class FTexture;
class FGameTexture;
FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename);
FGameTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename);
#endif

View file

@ -276,7 +276,6 @@ public:
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; }
bool isMiscPatch() const { return UseType == ETextureType::MiscPatch; } // only used by the intermission screen to decide whether to tile the background image or not.
int isWarped() const { return bWarped; }
int GetRotations() const { return Rotations; }
float GetShaderSpeed() const { return shaderspeed; }
@ -590,6 +589,7 @@ public:
bool isValid() { return wrapped.isValid(); }
bool isWarped() { return wrapped.isWarped(); }
bool isMiscPatch() const { return wrapped.GetUseType() == ETextureType::MiscPatch; } // only used by the intermission screen to decide whether to tile the background image or not.
bool useWorldPanning() { return wrapped.UseWorldPanning(); }
float GetShaderSpeed() const { return wrapped.GetShaderSpeed(); }
uint16_t GetRotations() const { return wrapped.GetRotations(); }

View file

@ -271,7 +271,7 @@ int eventhead;
int eventtail;
gamestate_t wipegamestate = GS_DEMOSCREEN; // can be -1 to force a wipe
bool PageBlank;
FTexture *Advisory;
FGameTexture *Advisory;
FTextureID Page;
const char *Subtitle;
bool nospriterename;
@ -1005,11 +1005,8 @@ void D_Display ()
// draw pause pic
if ((paused || pauseext) && menuactive == MENU_Off)
{
FTexture *tex;
int x;
tex = TexMan.GetTextureByName(gameinfo.PauseSign, true);
x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 +
auto tex = TexMan.GetGameTextureByName(gameinfo.PauseSign, true);
double x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 +
tex->GetDisplayLeftOffset() * CleanXfac;
DrawTexture(twod, tex, x, 4, DTA_CleanNoMove, true, TAG_DONE);
if (paused && multiplayer)
@ -1031,7 +1028,7 @@ void D_Display ()
D_DrawIcon = NULL;
if (picnum.isValid())
{
FTexture *tex = TexMan.GetTexture(picnum);
auto tex = TexMan.GetGameTexture(picnum);
DrawTexture(twod, tex, 160 - tex->GetDisplayWidth()/2, 100 - tex->GetDisplayHeight()/2,
DTA_320x200, true, TAG_DONE);
}
@ -1068,7 +1065,7 @@ void D_Display ()
screen->End2D();
auto wipend = screen->WipeEndScreen ();
auto wiper = Wiper::Create(wipe_type);
wiper->SetTextures(wipe, wipend);
wiper->SetTextures(reinterpret_cast<FGameTexture*>(wipe), reinterpret_cast<FGameTexture*>(wipend));
wipestart = I_msTime();
NetUpdate(); // send out any new accumulation
@ -1232,7 +1229,7 @@ void D_PageDrawer (void)
ClearRect(twod, 0, 0, SCREENWIDTH, SCREENHEIGHT, 0, 0);
if (Page.Exists())
{
DrawTexture(twod, TexMan.GetTexture(Page, true), 0, 0,
DrawTexture(twod, TexMan.GetGameTexture(Page, true), 0, 0,
DTA_Fullscreen, true,
DTA_Masked, false,
DTA_BilinearFilter, true,
@ -1433,7 +1430,7 @@ void D_DoAdvanceDemo (void)
case 3:
if (gameinfo.advisoryTime)
{
Advisory = TexMan.GetTextureByName("ADVISOR");
Advisory = TexMan.GetGameTextureByName("ADVISOR");
demosequence = 1;
pagetic = (int)(gameinfo.advisoryTime * TICRATE);
break;

View file

@ -429,7 +429,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
auto icon = FSetTextureID(player->mo->IntVar(NAME_ScoreIcon));
if (icon.isValid())
{
FTexture *pic = TexMan.GetTexture(icon);
auto pic = TexMan.GetGameTexture(icon);
DrawTexture(twod, pic, col3, y,
DTA_CleanNoMove, true,
TAG_DONE);
@ -450,7 +450,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
if (teamplay && Teams[player->userinfo.GetTeam()].GetLogo().IsNotEmpty ())
{
FTexture *pic = TexMan.GetTextureByName(Teams[player->userinfo.GetTeam()].GetLogo().GetChars ());
auto pic = TexMan.GetGameTextureByName(Teams[player->userinfo.GetTeam()].GetLogo().GetChars ());
DrawTexture(twod, pic, col1 - (pic->GetDisplayWidth() + 2) * CleanXfac, y,
DTA_CleanNoMove, true, TAG_DONE);
}

View file

@ -216,7 +216,7 @@ void DIntermissionScreen::Drawer ()
{
if (!mFlatfill)
{
DrawTexture(twod, TexMan.GetTexture(mBackground), 0, 0, DTA_Fullscreen, true, TAG_DONE);
DrawTexture(twod, TexMan.GetGameTexture(mBackground), 0, 0, DTA_Fullscreen, true, TAG_DONE);
}
else
{
@ -230,7 +230,7 @@ void DIntermissionScreen::Drawer ()
for (unsigned i=0; i < mOverlays.Size(); i++)
{
if (CheckOverlay(i))
DrawTexture(twod, TexMan.GetTexture(mOverlays[i].mPic), mOverlays[i].x, mOverlays[i].y, DTA_320x200, true, TAG_DONE);
DrawTexture(twod, TexMan.GetGameTexture(mOverlays[i].mPic), mOverlays[i].x, mOverlays[i].y, DTA_320x200, true, TAG_DONE);
}
if (mSubtitle)
{
@ -287,11 +287,11 @@ void DIntermissionScreenFader::Drawer ()
if (mType == FADE_In) factor = 1.0 - factor;
int color = MAKEARGB(int(factor*255), 0,0,0);
DrawTexture(twod, TexMan.GetTexture(mBackground), 0, 0, DTA_Fullscreen, true, DTA_ColorOverlay, color, TAG_DONE);
DrawTexture(twod, TexMan.GetGameTexture(mBackground), 0, 0, DTA_Fullscreen, true, DTA_ColorOverlay, color, TAG_DONE);
for (unsigned i=0; i < mOverlays.Size(); i++)
{
if (CheckOverlay(i))
DrawTexture(twod, TexMan.GetTexture(mOverlays[i].mPic), mOverlays[i].x, mOverlays[i].y, DTA_320x200, true, DTA_ColorOverlay, color, TAG_DONE);
DrawTexture(twod, TexMan.GetGameTexture(mOverlays[i].mPic), mOverlays[i].x, mOverlays[i].y, DTA_320x200, true, DTA_ColorOverlay, color, TAG_DONE);
}
}
}
@ -620,7 +620,6 @@ int DIntermissionScreenCast::Ticker ()
void DIntermissionScreenCast::Drawer ()
{
spriteframe_t* sprframe;
FTexture* pic;
Super::Drawer();
@ -667,13 +666,13 @@ void DIntermissionScreenCast::Drawer ()
}
sprframe = &SpriteFrames[sprites[castsprite].spriteframes + caststate->GetFrame()];
pic = TexMan.GetTexture(sprframe->Texture[0], true);
auto pic = TexMan.GetGameTexture(sprframe->Texture[0], true);
DrawTexture(twod, pic, 160, 170,
DTA_320x200, true,
DTA_FlipX, sprframe->Flip & 1,
DTA_DestHeightF, pic->GetDisplayHeightDouble() * castscale.Y,
DTA_DestWidthF, pic->GetDisplayWidthDouble() * castscale.X,
DTA_DestHeightF, pic->GetDisplayHeight() * castscale.Y,
DTA_DestWidthF, pic->GetDisplayWidth() * castscale.X,
DTA_RenderStyle, mDefaults->RenderStyle,
DTA_Alpha, mDefaults->Alpha,
DTA_TranslationIndex, casttranslation,
@ -710,13 +709,13 @@ int DIntermissionScreenScroller::Responder (event_t *ev)
void DIntermissionScreenScroller::Drawer ()
{
FTexture *tex = TexMan.GetTexture(mFirstPic);
FTexture *tex2 = TexMan.GetTexture(mSecondPic);
auto tex = TexMan.GetGameTexture(mFirstPic);
auto tex2 = TexMan.GetGameTexture(mSecondPic);
if (mTicker >= mScrollDelay && mTicker < mScrollDelay + mScrollTime && tex != NULL && tex2 != NULL)
{
int fwidth = tex->GetDisplayWidth();
int fheight = tex->GetDisplayHeight();
// These must round down to the nearest full pixel to cover seams between the two textures.
int fwidth = (int)tex->GetDisplayWidth();
int fheight = (int)tex->GetDisplayHeight();
double xpos1 = 0, ypos1 = 0, xpos2 = 0, ypos2 = 0;

View file

@ -73,7 +73,7 @@ private:
int LastSaved = -1;
int LastAccessed = -1;
TArray<char> SavePicData;
FTexture *SavePic = nullptr;
FGameTexture *SavePic = nullptr;
public:
int WindowSize = 0;

View file

@ -168,7 +168,7 @@ class Wiper_Burn : public Wiper
public:
~Wiper_Burn();
bool Run(int ticks) override;
void SetTextures(FTexture *startscreen, FTexture *endscreen) override;
void SetTextures(FGameTexture *startscreen, FGameTexture *endscreen) override;
private:
static const int WIDTH = 64, HEIGHT = 64;
@ -307,8 +307,8 @@ bool Wiper_Melt::Run(int ticks)
// Only draw for the final tick.
// No need for optimization. Wipes won't ever be drawn with anything else.
int w = startScreen->GetDisplayWidth();
int h = startScreen->GetDisplayHeight();
int w = startScreen->GetTexelWidth();
int h = startScreen->GetTexelHeight();
dpt.x = i * w / WIDTH;
dpt.y = MAX(0, y[i] * h / HEIGHT);
rect.left = dpt.x;
@ -331,12 +331,12 @@ bool Wiper_Melt::Run(int ticks)
//
//==========================================================================
void Wiper_Burn::SetTextures(FTexture *startscreen, FTexture *endscreen)
void Wiper_Burn::SetTextures(FGameTexture *startscreen, FGameTexture *endscreen)
{
startScreen = startscreen;
endScreen = endscreen;
BurnTexture = new FBurnTexture(WIDTH, HEIGHT);
auto mat = FMaterial::ValidateTexture(endScreen, false);
auto mat = FMaterial::ValidateTexture(endScreen->GetTexture(), false);
mat->AddTextureLayer(BurnTexture);
}
@ -374,7 +374,7 @@ bool Wiper_Burn::Run(int ticks)
}
BurnTexture->CleanHardwareTextures(true, true);
endScreen->CleanHardwareTextures(false, false);
endScreen->GetTexture()->CleanHardwareTextures(false, false);
const uint8_t *src = BurnArray;
uint32_t *dest = (uint32_t *)BurnTexture->GetBuffer();

View file

@ -43,11 +43,11 @@ enum
class Wiper
{
protected:
FTexture *startScreen = nullptr, *endScreen = nullptr;
FGameTexture *startScreen = nullptr, *endScreen = nullptr;
public:
virtual ~Wiper();
virtual bool Run(int ticks) = 0;
virtual void SetTextures(FTexture *startscreen, FTexture *endscreen)
virtual void SetTextures(FGameTexture *startscreen, FGameTexture *endscreen)
{
startScreen = startscreen;
endScreen = endscreen;

View file

@ -116,7 +116,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
systemTexture->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, "swbuffer");
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
DrawTexture(twod, fbtex.get(), 0, 0, DTA_SpecialColormap, map, TAG_DONE);
DrawTexture(twod, reinterpret_cast<FGameTexture*>(fbtex.get()), 0, 0, DTA_SpecialColormap, map, TAG_DONE);
screen->Draw2D();
screen->Clear2D();
screen->PostProcessScene(CM_DEFAULT, [&]() {

View file

@ -522,7 +522,7 @@ IHardwareTexture* CreateHardwareTexture()
void DrawFrame(F2DDrawer* drawer, int left, int top, int width, int height)
{
FTexture* p;
FGameTexture* p;
const gameborder_t* border = &gameinfo.Border;
// Sanity check for incomplete gameinfo
if (border == NULL)
@ -532,22 +532,22 @@ void DrawFrame(F2DDrawer* drawer, int left, int top, int width, int height)
int bottom = top + height;
// Draw top and bottom sides.
p = TexMan.GetTextureByName(border->t);
drawer->AddFlatFill(left, top - p->GetDisplayHeight(), right, top, p, true);
p = TexMan.GetTextureByName(border->b);
drawer->AddFlatFill(left, bottom, right, bottom + p->GetDisplayHeight(), p, true);
p = TexMan.GetGameTextureByName(border->t);
drawer->AddFlatFill(left, top - (int)p->GetDisplayHeight(), right, top, p, true);
p = TexMan.GetGameTextureByName(border->b);
drawer->AddFlatFill(left, bottom, right, bottom + (int)p->GetDisplayHeight(), p, true);
// Draw left and right sides.
p = TexMan.GetTextureByName(border->l);
drawer->AddFlatFill(left - p->GetDisplayWidth(), top, left, bottom, p, true);
p = TexMan.GetTextureByName(border->r);
drawer->AddFlatFill(right, top, right + p->GetDisplayWidth(), bottom, p, true);
p = TexMan.GetGameTextureByName(border->l);
drawer->AddFlatFill(left - (int)p->GetDisplayWidth(), top, left, bottom, p, true);
p = TexMan.GetGameTextureByName(border->r);
drawer->AddFlatFill(right, top, right + (int)p->GetDisplayWidth(), bottom, p, true);
// Draw beveled corners.
DrawTexture(drawer, TexMan.GetTextureByName(border->tl), left - offset, top - offset, TAG_DONE);
DrawTexture(drawer, TexMan.GetTextureByName(border->tr), left + width, top - offset, TAG_DONE);
DrawTexture(drawer, TexMan.GetTextureByName(border->bl), left - offset, top + height, TAG_DONE);
DrawTexture(drawer, TexMan.GetTextureByName(border->br), left + width, top + height, TAG_DONE);
DrawTexture(drawer, TexMan.GetGameTextureByName(border->tl), left - offset, top - offset, TAG_DONE);
DrawTexture(drawer, TexMan.GetGameTextureByName(border->tr), left + width, top - offset, TAG_DONE);
DrawTexture(drawer, TexMan.GetGameTextureByName(border->bl), left - offset, top + height, TAG_DONE);
DrawTexture(drawer, TexMan.GetGameTextureByName(border->br), left + width, top + height, TAG_DONE);
}
DEFINE_ACTION_FUNCTION(_Screen, DrawFrame)

View file

@ -138,7 +138,7 @@ class DInterBackground : public DObject
int period; // period in tics between animations
yahpt_t loc; // location of animation
int data; // ALWAYS: n/a, RANDOM: period deviation (<256)
TArray<FTexture*> frames; // actual graphics for frames of animations
TArray<FGameTexture*> frames; // actual graphics for frames of animations
// following must be initialized to zero before use!
int nexttic; // next value of bcnt (used in conjunction with period)
@ -161,9 +161,9 @@ private:
TArray<lnode_t> lnodes;
TArray<in_anim_t> anims;
int bcnt = 0; // used for timing of background animation
TArray<FTexture *> yah; // You Are Here graphic
FTexture* splat = nullptr; // splat
FTexture *background = nullptr;
TArray<FGameTexture *> yah; // You Are Here graphic
FGameTexture* splat = nullptr; // splat
FGameTexture *background = nullptr;
wbstartstruct_t *wbs;
level_info_t *exitlevel;
@ -208,15 +208,15 @@ private:
//
//====================================================================
void drawOnLnode(int n, FTexture * c[], int numc)
void drawOnLnode(int n, FGameTexture * c[], int numc)
{
int i;
for (i = 0; i<numc; i++)
{
int left;
int top;
int right;
int bottom;
double left;
double top;
double right;
double bottom;
right = c[i]->GetDisplayWidth();
@ -387,13 +387,13 @@ bool DInterBackground::LoadBackground(bool isenterpic)
case 1: // Splat
sc.MustGetString();
splat = TexMan.GetTextureByName(sc.String);
splat = TexMan.GetGameTextureByName(sc.String);
break;
case 2: // Pointers
while (sc.GetString() && !sc.Crossed)
{
yah.Push(TexMan.GetTextureByName(sc.String));
yah.Push(TexMan.GetGameTextureByName(sc.String));
}
if (sc.Crossed)
sc.UnGet();
@ -485,14 +485,14 @@ bool DInterBackground::LoadBackground(bool isenterpic)
if (!sc.CheckString("{"))
{
sc.MustGetString();
an.frames.Push(TexMan.GetTextureByName(sc.String));
an.frames.Push(TexMan.GetGameTextureByName(sc.String));
}
else
{
while (!sc.CheckString("}"))
{
sc.MustGetString();
an.frames.Push(TexMan.GetTextureByName(sc.String));
an.frames.Push(TexMan.GetGameTextureByName(sc.String));
}
}
an.ctr = -1;
@ -507,7 +507,7 @@ bool DInterBackground::LoadBackground(bool isenterpic)
an.loc.y = sc.Number;
sc.MustGetString();
an.frames.Reserve(1); // allocate exactly one element
an.frames[0] = TexMan.GetTextureByName(sc.String);
an.frames[0] = TexMan.GetGameTextureByName(sc.String);
anims.Push(an);
break;
@ -523,7 +523,7 @@ bool DInterBackground::LoadBackground(bool isenterpic)
texture = TexMan.GetTextureID("INTERPIC", ETextureType::MiscPatch);
}
}
background = TexMan.GetTexture(texture);
background = TexMan.GetGameTexture(texture);
return noautostartmap;
}
@ -598,8 +598,8 @@ void DInterBackground::drawBackground(int state, bool drawsplat, bool snl_pointe
// scale all animations below to fit the size of the base pic
// The base pic is always scaled to fit the screen so this allows
// placing the animations precisely where they belong on the base pic
animwidth = background->GetDisplayWidthDouble();
animheight = background->GetDisplayHeightDouble();
animwidth = background->GetDisplayWidth();
animheight = background->GetDisplayHeight();
DrawTexture(twod, background, 0, 0, DTA_Fullscreen, true, TAG_DONE);
}
else