diff --git a/src/common/2d/v_draw.h b/src/common/2d/v_draw.h index 5aebfd8332..bd0a27df61 100644 --- a/src/common/2d/v_draw.h +++ b/src/common/2d/v_draw.h @@ -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 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)...); } diff --git a/src/common/textures/formats/pngtexture.cpp b/src/common/textures/formats/pngtexture.cpp index 794892c6c7..36ce398d35 100644 --- a/src/common/textures/formats/pngtexture.cpp +++ b/src/common/textures/formats/pngtexture.cpp @@ -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(new FPNGFileTexture (png->File, width, height, colortype)); } //========================================================================== diff --git a/src/common/textures/m_png.h b/src/common/textures/m_png.h index 12e6d5adf5..2f52a1fcf5 100644 --- a/src/common/textures/m_png.h +++ b/src/common/textures/m_png.h @@ -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 diff --git a/src/common/textures/textures.h b/src/common/textures/textures.h index 6d32360d09..d889f97e13 100644 --- a/src/common/textures/textures.h +++ b/src/common/textures/textures.h @@ -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(); } diff --git a/src/d_main.cpp b/src/d_main.cpp index 70a95aa05f..0e9f269d1a 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -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(wipe), reinterpret_cast(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; diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index d8dce6a455..d393cfb4d2 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -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); } diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index a06feac8f9..b2ce4a5b27 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -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; diff --git a/src/menu/menu.h b/src/menu/menu.h index 98fd2addbb..ed224e9608 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -73,7 +73,7 @@ private: int LastSaved = -1; int LastAccessed = -1; TArray SavePicData; - FTexture *SavePic = nullptr; + FGameTexture *SavePic = nullptr; public: int WindowSize = 0; diff --git a/src/rendering/2d/f_wipe.cpp b/src/rendering/2d/f_wipe.cpp index f255774918..6fe106646d 100644 --- a/src/rendering/2d/f_wipe.cpp +++ b/src/rendering/2d/f_wipe.cpp @@ -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(); diff --git a/src/rendering/2d/f_wipe.h b/src/rendering/2d/f_wipe.h index c639307aa6..9b16b4d38d 100644 --- a/src/rendering/2d/f_wipe.h +++ b/src/rendering/2d/f_wipe.h @@ -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; diff --git a/src/rendering/swrenderer/r_swscene.cpp b/src/rendering/swrenderer/r_swscene.cpp index aea5501036..dc7dcad8ba 100644 --- a/src/rendering/swrenderer/r_swscene.cpp +++ b/src/rendering/swrenderer/r_swscene.cpp @@ -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(fbtex.get()), 0, 0, DTA_SpecialColormap, map, TAG_DONE); screen->Draw2D(); screen->Clear2D(); screen->PostProcessScene(CM_DEFAULT, [&]() { diff --git a/src/rendering/v_video.cpp b/src/rendering/v_video.cpp index 3c75aa73cb..a4c59283e2 100644 --- a/src/rendering/v_video.cpp +++ b/src/rendering/v_video.cpp @@ -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) diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index 5e65cd292b..4334d170d9 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -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 frames; // actual graphics for frames of animations + TArray 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 lnodes; TArray anims; int bcnt = 0; // used for timing of background animation - TArray yah; // You Are Here graphic - FTexture* splat = nullptr; // splat - FTexture *background = nullptr; + TArray 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; iGetDisplayWidth(); @@ -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