diff --git a/src/common/fonts/font.cpp b/src/common/fonts/font.cpp index 9543c5363..f690c94e4 100644 --- a/src/common/fonts/font.cpp +++ b/src/common/fonts/font.cpp @@ -327,14 +327,14 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla } auto orig = pic->GetTexture(); - auto tex = MakeGameTexture(orig, ETextureType::FontChar); + auto tex = MakeGameTexture(orig, nullptr, ETextureType::FontChar); tex->CopySize(pic); TexMan.AddGameTexture(tex); Chars[i].OriginalPic = tex; if (!noTranslate) { - Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1(orig->GetImage()), ""), ETextureType::FontChar); + Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1(orig->GetImage())), nullptr, ETextureType::FontChar); Chars[i].TranslatedPic->CopySize(pic); TexMan.AddGameTexture(Chars[i].TranslatedPic); } @@ -410,14 +410,14 @@ void FFont::ReadSheetFont(TArray &folderdata, int width, int height part[0].OriginY = -height * y; part[0].Image = tex->GetTexture()->GetImage(); FMultiPatchTexture *image = new FMultiPatchTexture(width, height, part, false, false); - FImageTexture *tex = new FImageTexture(image, ""); + FImageTexture *tex = new FImageTexture(image); tex->bMultiPatch = true; tex->bMasked = true; tex->bTranslucent = -1; tex->bWorldPanning = true; tex->bNoDecals = false; tex->SourceLump = -1; // We do not really care. - auto gtex = MakeGameTexture(tex, ETextureType::FontChar); + auto gtex = MakeGameTexture(tex, nullptr, ETextureType::FontChar); gtex->SetOffsets(0, 0, 0); gtex->SetOffsets(1, 0, 0); gtex->SetScale((float)Scale.X, (float)Scale.Y); @@ -451,10 +451,10 @@ void FFont::ReadSheetFont(TArray &folderdata, int width, int height auto b = pic->Get8BitPixels(false); - Chars[i].OriginalPic = MakeGameTexture(pic, ETextureType::FontChar); + Chars[i].OriginalPic = MakeGameTexture(pic, nullptr, ETextureType::FontChar); Chars[i].OriginalPic->SetUseType(ETextureType::FontChar); Chars[i].OriginalPic->CopySize(*lump); - Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1(pic->GetImage()), ""), ETextureType::FontChar); + Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1(pic->GetImage())), nullptr, ETextureType::FontChar); Chars[i].TranslatedPic->CopySize(*lump); Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); TexMan.AddGameTexture(Chars[i].OriginalPic); diff --git a/src/common/fonts/hexfont.cpp b/src/common/fonts/hexfont.cpp index 4b3fd39cd..812973bba 100644 --- a/src/common/fonts/hexfont.cpp +++ b/src/common/fonts/hexfont.cpp @@ -289,7 +289,7 @@ public: { auto offset = hexdata.glyphmap[i]; int size = hexdata.glyphdata[offset] / 16; - Chars[i - FirstChar].TranslatedPic = MakeGameTexture(new FImageTexture(new FHexFontChar (&hexdata.glyphdata[offset+1], size, size * 9, 16)), ETextureType::FontChar); + Chars[i - FirstChar].TranslatedPic = MakeGameTexture(new FImageTexture(new FHexFontChar (&hexdata.glyphdata[offset+1], size, size * 9, 16)), nullptr, ETextureType::FontChar); Chars[i - FirstChar].XMove = size * spacing; TexMan.AddGameTexture(Chars[i - FirstChar].TranslatedPic); } @@ -361,7 +361,7 @@ public: { auto offset = hexdata.glyphmap[i]; int size = hexdata.glyphdata[offset] / 16; - Chars[i - FirstChar].TranslatedPic = MakeGameTexture(new FImageTexture(new FHexFontChar2(&hexdata.glyphdata[offset + 1], size, 2 + size * 8, 18)), ETextureType::FontChar); + Chars[i - FirstChar].TranslatedPic = MakeGameTexture(new FImageTexture(new FHexFontChar2(&hexdata.glyphdata[offset + 1], size, 2 + size * 8, 18)), nullptr, ETextureType::FontChar); Chars[i - FirstChar].XMove = size * spacing; TexMan.AddGameTexture(Chars[i - FirstChar].TranslatedPic); } diff --git a/src/common/fonts/singlelumpfont.cpp b/src/common/fonts/singlelumpfont.cpp index ad81f3d0f..ed69aea80 100644 --- a/src/common/fonts/singlelumpfont.cpp +++ b/src/common/fonts/singlelumpfont.cpp @@ -353,7 +353,7 @@ void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data) } else { - Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar2 (lump, int(data_p - data), widths2[i], FontHeight)), ETextureType::FontChar); + Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar2 (lump, int(data_p - data), widths2[i], FontHeight)), nullptr, ETextureType::FontChar); TexMan.AddGameTexture(Chars[i].TranslatedPic); do { @@ -487,7 +487,7 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data) chardata[chari+2], // height -(int8_t)chardata[chari+3], // x offset -(int8_t)chardata[chari+4] // y offset - )), ETextureType::FontChar); + )), nullptr, ETextureType::FontChar); Chars[chardata[chari] - FirstChar].TranslatedPic = tex; TexMan.AddGameTexture(tex); } @@ -554,7 +554,7 @@ void FSingleLumpFont::CheckFON1Chars (double *luminosity) if(!Chars[i].TranslatedPic) { - Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar2 (Lump, int(data_p - data), SpaceWidth, FontHeight)), ETextureType::FontChar); + Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar2 (Lump, int(data_p - data), SpaceWidth, FontHeight)), nullptr, ETextureType::FontChar); Chars[i].XMove = SpaceWidth; TexMan.AddGameTexture(Chars[i].TranslatedPic); } diff --git a/src/common/fonts/specialfont.cpp b/src/common/fonts/specialfont.cpp index 9c6c33a81..6bd544c9e 100644 --- a/src/common/fonts/specialfont.cpp +++ b/src/common/fonts/specialfont.cpp @@ -104,13 +104,13 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FGameTexture if (charlumps[i] != nullptr) { auto pic = charlumps[i]; - Chars[i].OriginalPic = MakeGameTexture(pic->GetTexture(), ETextureType::FontChar); + Chars[i].OriginalPic = MakeGameTexture(pic->GetTexture(), nullptr, ETextureType::FontChar); Chars[i].OriginalPic->CopySize(pic); TexMan.AddGameTexture(Chars[i].OriginalPic); if (!noTranslate) { - Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1 (charlumps[i]->GetTexture()->GetImage()), ""), ETextureType::FontChar); + Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1 (charlumps[i]->GetTexture()->GetImage())), nullptr, ETextureType::FontChar); Chars[i].TranslatedPic->CopySize(charlumps[i]); TexMan.AddGameTexture(Chars[i].TranslatedPic); } diff --git a/src/common/textures/formats/pngtexture.cpp b/src/common/textures/formats/pngtexture.cpp index a808dd13b..0357b0da9 100644 --- a/src/common/textures/formats/pngtexture.cpp +++ b/src/common/textures/formats/pngtexture.cpp @@ -609,7 +609,7 @@ FGameTexture *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 MakeGameTexture(new FPNGFileTexture (png->File, width, height, colortype), ETextureType::Override); + else return MakeGameTexture(new FPNGFileTexture (png->File, width, height, colortype), nullptr, ETextureType::Override); } //========================================================================== diff --git a/src/common/textures/formats/shadertexture.cpp b/src/common/textures/formats/shadertexture.cpp index 21fd89356..6bde2b677 100644 --- a/src/common/textures/formats/shadertexture.cpp +++ b/src/common/textures/formats/shadertexture.cpp @@ -132,6 +132,6 @@ private: FGameTexture *CreateShaderTexture(bool vertical, bool reverse) { FStringf name("BarShader%c%c", vertical ? 'v' : 'h', reverse ? 'r' : 'f'); - return MakeGameTexture(CreateImageTexture(new FBarShader(vertical, reverse), name.GetChars()), ETextureType::Override); + return MakeGameTexture(CreateImageTexture(new FBarShader(vertical, reverse)), name.GetChars(), ETextureType::Override); } diff --git a/src/common/textures/image.h b/src/common/textures/image.h index 38e5a2ee1..6ddd34bc2 100644 --- a/src/common/textures/image.h +++ b/src/common/textures/image.h @@ -171,4 +171,4 @@ protected: class FTexture; -FTexture* CreateImageTexture(FImageSource* img, const char *name = nullptr) noexcept; +FTexture* CreateImageTexture(FImageSource* img) noexcept; diff --git a/src/common/textures/imagetexture.cpp b/src/common/textures/imagetexture.cpp index ba4179b8a..bde19f8b8 100644 --- a/src/common/textures/imagetexture.cpp +++ b/src/common/textures/imagetexture.cpp @@ -47,13 +47,12 @@ // //========================================================================== -FImageTexture::FImageTexture(FImageSource *img, const char *name) noexcept -: FTexture(name, img? img->LumpNum() : 0) +FImageTexture::FImageTexture(FImageSource *img) noexcept +: FTexture(img? img->LumpNum() : 0) { mImage = img; if (img != nullptr) { - if (name == nullptr) fileSystem.GetFileShortName(Name, img->LumpNum()); SetFromImage(); } } @@ -109,8 +108,8 @@ bool FImageTexture::DetermineTranslucency() } -FTexture* CreateImageTexture(FImageSource* img, const char *name) noexcept +FTexture* CreateImageTexture(FImageSource* img) noexcept { - return new FImageTexture(img, name); + return new FImageTexture(img); } diff --git a/src/common/textures/multipatchtexturebuilder.cpp b/src/common/textures/multipatchtexturebuilder.cpp index 2c1ce45fe..ea55239d7 100644 --- a/src/common/textures/multipatchtexturebuilder.cpp +++ b/src/common/textures/multipatchtexturebuilder.cpp @@ -137,7 +137,7 @@ struct FPatchLookup void FMultipatchTextureBuilder::MakeTexture(BuildInfo &buildinfo, ETextureType usetype) { - FImageTexture *tex = new FImageTexture(nullptr, buildinfo.Name); + FImageTexture *tex = new FImageTexture(nullptr); tex->bMultiPatch = true; tex->SetSize(buildinfo.Width, buildinfo.Height); tex->bMasked = true; // we do not really know yet. @@ -145,7 +145,7 @@ void FMultipatchTextureBuilder::MakeTexture(BuildInfo &buildinfo, ETextureType u tex->bNoDecals = buildinfo.bNoDecals; tex->SourceLump = buildinfo.DefinitionLump; buildinfo.itex = tex; - buildinfo.texture = MakeGameTexture(tex, usetype); + buildinfo.texture = MakeGameTexture(tex, buildinfo.Name, usetype); buildinfo.texture->SetOffsets(0, buildinfo.LeftOffset[0], buildinfo.TopOffset[0]); buildinfo.texture->SetOffsets(1, buildinfo.LeftOffset[1], buildinfo.TopOffset[1]); buildinfo.texture->SetScale((float)buildinfo.Scale.X, (float)buildinfo.Scale.X); diff --git a/src/common/textures/skyboxtexture.cpp b/src/common/textures/skyboxtexture.cpp index 0c2820be2..b77a2ad3b 100644 --- a/src/common/textures/skyboxtexture.cpp +++ b/src/common/textures/skyboxtexture.cpp @@ -35,7 +35,7 @@ //----------------------------------------------------------------------------- FSkyBox::FSkyBox(const char *name) - : FImageTexture(name) + : FImageTexture(nullptr) { FTextureID texid = TexMan.CheckForTexture(name, ETextureType::Wall); if (texid.isValid()) diff --git a/src/common/textures/texture.cpp b/src/common/textures/texture.cpp index 0e699a52c..94f9309a7 100644 --- a/src/common/textures/texture.cpp +++ b/src/common/textures/texture.cpp @@ -70,20 +70,14 @@ int r_spriteadjustSW, r_spriteadjustHW; // Examines the lump contents to decide what type of texture to create, // and creates the texture. -FTexture * FTexture::CreateTexture(const char *name, int lumpnum, bool allowflats) +FTexture * FTexture::CreateTexture(int lumpnum, bool allowflats) { if (lumpnum == -1) return nullptr; auto image = FImageSource::GetImage(lumpnum, allowflats); if (image != nullptr) { - FTexture *tex = new FImageTexture(image); - if (tex != nullptr) - { - tex->Name = name; - tex->Name.ToUpper(); - return tex; - } + return new FImageTexture(image); } return nullptr; } @@ -94,7 +88,7 @@ FTexture * FTexture::CreateTexture(const char *name, int lumpnum, bool allowflat // //========================================================================== -FTexture::FTexture (const char *name, int lumpnum) +FTexture::FTexture (int lumpnum) : SourceLump(lumpnum), bNoDecals(false), bNoRemap0(false), bWorldPanning(false), @@ -109,21 +103,6 @@ FTexture::FTexture (const char *name, int lumpnum) bSkybox = false; bNoCompress = false; bTranslucent = -1; - - - if (name != NULL) - { - Name = name; - Name.ToUpper(); - } - else if (lumpnum < 0) - { - Name = FString(); - } - else - { - fileSystem.GetFileShortName (Name, lumpnum); - } } FTexture::~FTexture () @@ -971,7 +950,7 @@ FWrapperTexture::FWrapperTexture(int w, int h, int bits) } -FGameTexture::FGameTexture(FTexture* wrap) : Base(wrap) +FGameTexture::FGameTexture(FTexture* wrap, const char *name) : Base(wrap), Name(name) { id.SetInvalid(); TexelWidth = Base->GetWidth(); diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index 1e0ee8e88..5ff1ad657 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -230,7 +230,7 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset if (tex == NO_TEXTURE) return FTextureID(-1); if (tex != NULL) return tex->GetID(); if (flags & TEXMAN_DontCreate) return FTextureID(-1); // we only want to check, there's no need to create a texture if we don't have one yet. - tex = MakeGameTexture(FTexture::CreateTexture("", lump), ETextureType::Override); + tex = MakeGameTexture(FTexture::CreateTexture(lump), nullptr, ETextureType::Override); if (tex != NULL) { tex->AddAutoMaterials(); @@ -421,7 +421,7 @@ FTextureID FTextureManager::CreateTexture (int lumpnum, ETextureType usetype) { FString str; fileSystem.GetFileShortName(str, lumpnum); - auto out = MakeGameTexture(FTexture::CreateTexture(str, lumpnum, usetype == ETextureType::Flat), usetype); + auto out = MakeGameTexture(FTexture::CreateTexture(lumpnum, usetype == ETextureType::Flat), str, usetype); if (out != NULL) { @@ -470,11 +470,11 @@ void FTextureManager::ReplaceTexture (FTextureID picnum, FGameTexture *newtextur auto oldtexture = Textures[index].Texture; - newtexture->GetTexture()->Name = oldtexture->GetName(); + newtexture->SetName(oldtexture->GetName()); newtexture->SetUseType(oldtexture->GetUseType()); Textures[index].Texture = newtexture; newtexture->SetID(oldtexture->GetID()); - oldtexture->GetTexture()->Name = ""; + oldtexture->SetName(""); AddGameTexture(oldtexture); } @@ -584,7 +584,7 @@ void FTextureManager::AddHiresTextures (int wadnum) if (amount == 0) { // A texture with this name does not yet exist - auto newtex = MakeGameTexture(FTexture::CreateTexture (Name, firsttx), ETextureType::Override); + auto newtex = MakeGameTexture(FTexture::CreateTexture(firsttx), Name, ETextureType::Override); if (newtex != NULL) { AddGameTexture(newtex); @@ -594,13 +594,13 @@ void FTextureManager::AddHiresTextures (int wadnum) { for(unsigned int i = 0; i < tlist.Size(); i++) { - FTexture * newtex = FTexture::CreateTexture ("", firsttx); + FTexture * newtex = FTexture::CreateTexture (firsttx); if (newtex != NULL) { auto oldtex = Textures[tlist[i].GetIndex()].Texture; // Replace the entire texture and adjust the scaling and offset factors. - auto gtex = MakeGameTexture(newtex, ETextureType::Override); + auto gtex = MakeGameTexture(newtex, nullptr, ETextureType::Override); gtex->SetWorldPanning(true); gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight()); gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetDisplayLeftOffset(0) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetDisplayTopOffset(0) * gtex->GetScaleY())); @@ -692,11 +692,11 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build (sl=oldtex->GetSourceLump()) >= 0 && fileSystem.GetFileNamespace(sl) == ns_sprites) ) { - FTexture * newtex = FTexture::CreateTexture ("", lumpnum); + FTexture * newtex = FTexture::CreateTexture (lumpnum); if (newtex != NULL) { // Replace the entire texture and adjust the scaling and offset factors. - auto gtex = MakeGameTexture(newtex, ETextureType::Override); + auto gtex = MakeGameTexture(newtex, nullptr, ETextureType::Override); gtex->SetWorldPanning(true); gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight()); gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetDisplayLeftOffset(0) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetDisplayTopOffset(0) * gtex->GetScaleY())); @@ -730,7 +730,7 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build if (lumpnum>=0) { - auto newtex = MakeGameTexture(FTexture::CreateTexture(src, lumpnum), ETextureType::Override); + auto newtex = MakeGameTexture(FTexture::CreateTexture(lumpnum), src, ETextureType::Override); if (newtex != NULL) { @@ -950,7 +950,7 @@ void FTextureManager::AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &b // Try to create a texture from this lump and add it. // Unfortunately we have to look at everything that comes through here... - auto out = MakeGameTexture(FTexture::CreateTexture(Name, i), skin ? ETextureType::SkinGraphic : ETextureType::MiscPatch); + auto out = MakeGameTexture(FTexture::CreateTexture(i), Name, skin ? ETextureType::SkinGraphic : ETextureType::MiscPatch); if (out != NULL) { @@ -1116,11 +1116,11 @@ void FTextureManager::Init(void (*progressFunc_)(), void (*checkForHacks)(BuildI DeleteAll(); //if (BuildTileFiles.Size() == 0) CountBuildTiles (); - auto nulltex = MakeGameTexture(new FImageTexture(CreateEmptyTexture(), ""), ETextureType::Null); + auto nulltex = MakeGameTexture(new FImageTexture(CreateEmptyTexture()), nullptr, ETextureType::Null); AddGameTexture(nulltex); // This is for binding to unused texture units, because accessing an unbound texture unit is undefined. It's a one pixel empty texture. - auto emptytex = MakeGameTexture(new FImageTexture(CreateEmptyTexture(), ""), ETextureType::Override); + auto emptytex = MakeGameTexture(new FImageTexture(CreateEmptyTexture()), nullptr, ETextureType::Override); emptytex->SetSize(1, 1); AddGameTexture(emptytex); // some special textures used in the game. @@ -1235,7 +1235,7 @@ FTextureID FTextureManager::GetRawTexture(FTextureID texid) } // Todo: later this can just link to the already existing texture for this source graphic, once it can be retrieved through the image's SourceLump index - auto RawTexture = MakeGameTexture(new FImageTexture(source, ""), ETextureType::Wall); + auto RawTexture = MakeGameTexture(new FImageTexture(source), nullptr, ETextureType::Wall); texid = TexMan.AddGameTexture(RawTexture); Textures[texidx].RawTexture = texid.GetIndex(); Textures[texid.GetIndex()].RawTexture = texid.GetIndex(); @@ -1268,7 +1268,7 @@ FTextureID FTextureManager::GetFrontSkyLayer(FTextureID texid) // Set this up so that it serializes to the same info as the base texture - this is needed to restore it on load. // But do not link the new texture into the hash chain! - auto FrontSkyLayer = MakeGameTexture(new FImageTexture(image, tex->GetName()), ETextureType::Wall); + auto FrontSkyLayer = MakeGameTexture(new FImageTexture(image), tex->GetName(), ETextureType::Wall); FrontSkyLayer->SetUseType(tex->GetUseType()); FrontSkyLayer->GetTexture()->bNoRemap0 = true; texid = TexMan.AddGameTexture(FrontSkyLayer, false); diff --git a/src/common/textures/textures.h b/src/common/textures/textures.h index b80e9a462..7251ab90f 100644 --- a/src/common/textures/textures.h +++ b/src/common/textures/textures.h @@ -250,7 +250,7 @@ class FTexture : public RefCountedBase public: IHardwareTexture* GetHardwareTexture(int translation, int scaleflags); - static FTexture *CreateTexture(const char *name, int lumpnum, bool allowflats = false); + static FTexture *CreateTexture(int lumpnum, bool allowflats = false); virtual ~FTexture (); virtual FImageSource *GetImage() const { return nullptr; } void CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha, bool checkonly); @@ -268,7 +268,6 @@ public: float GetShaderSpeed() const { return shaderspeed; } void SetRotations(int rot) { Rotations = int16_t(rot); } - const FString &GetName() const { return Name; } void SetNoDecals(bool on) { bNoDecals = on; } void SetWarpStyle(int style) { bWarped = style; } bool allowNoDecals() const { return bNoDecals; } @@ -319,8 +318,6 @@ protected: protected: - FString Name; - uint8_t bNoDecals:1; // Decals should not stick to texture uint8_t bNoRemap0:1; // Do not remap color 0 (used by front layer of parallax skies) uint8_t bWorldPanning:1; // Texture is panned in world units rather than texels @@ -363,7 +360,7 @@ protected: protected: uint16_t Width, Height; - FTexture (const char *name = NULL, int lumpnum = -1); + FTexture (int lumpnum = -1); public: FTextureBuffer CreateTexBuffer(int translation, int flags = 0); @@ -388,9 +385,8 @@ public: class FCanvasTexture : public FTexture { public: - FCanvasTexture(const char* name, int width, int height) + FCanvasTexture(int width, int height) { - Name = name; Width = width; Height = height; @@ -438,10 +434,9 @@ class FImageTexture : public FTexture { FImageSource* mImage; protected: - FImageTexture(const char *name) : FTexture(name) {} void SetFromImage(); public: - FImageTexture(FImageSource* image, const char* name = nullptr) noexcept; + FImageTexture(FImageSource* image) noexcept; virtual TArray Get8BitPixels(bool alphatex); void SetImage(FImageSource* img) // This is only for the multipatch texture builder! @@ -543,6 +538,7 @@ class FGameTexture RefCountedPtr AmbientOcclusion; // Ambient occlusion texture for PBR RefCountedPtr CustomShaderTextures[MAX_CUSTOM_HW_SHADER_TEXTURES]; // Custom texture maps for custom hardware shaders + FString Name; FTextureID id; uint16_t TexelWidth, TexelHeight; @@ -558,10 +554,12 @@ class FGameTexture FMaterial* Material[4] = { }; public: - FGameTexture(FTexture* wrap); + FGameTexture(FTexture* wrap, const char *name); ~FGameTexture(); FTextureID GetID() const { return id; } void SetID(FTextureID newid) { id = newid; } // should only be called by the texture manager + const FString& GetName() const { return Name; } + void SetName(const char* name) { Name = name; } // should only be called by setup code. float GetScaleX() { return ScaleX; } float GetScaleY() { return ScaleY; } @@ -628,7 +626,6 @@ public: return Material[num]; } - const FString& GetName() const { return Base->GetName(); } void SetShaderSpeed(float speed) { Base->shaderspeed = speed; } void SetShaderIndex(int index) { Base->shaderindex = index; } void SetShaderLayers(MaterialLayers& lay) @@ -724,10 +721,10 @@ public: } }; -inline FGameTexture* MakeGameTexture(FTexture* tex, ETextureType useType) +inline FGameTexture* MakeGameTexture(FTexture* tex, const char *name, ETextureType useType) { if (!tex) return nullptr; - auto t = new FGameTexture(tex); + auto t = new FGameTexture(tex, name); t->SetUseType(useType); return t; } diff --git a/src/d_main.cpp b/src/d_main.cpp index eb8a22a0f..47eb81928 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -880,7 +880,7 @@ void D_Display () if (vr_mode == 0 || vid_rendermode != 4) { // save the current screen if about to wipe - wipe = MakeGameTexture(screen->WipeStartScreen(), ETextureType::SWCanvas); + wipe = MakeGameTexture(screen->WipeStartScreen(), nullptr, ETextureType::SWCanvas); switch (wipegamestate) { @@ -1063,7 +1063,7 @@ void D_Display () GSnd->SetSfxPaused(true, 1); I_FreezeTime(true); screen->End2D(); - auto wipend = MakeGameTexture(screen->WipeEndScreen(), ETextureType::SWCanvas); + auto wipend = MakeGameTexture(screen->WipeEndScreen(), nullptr, ETextureType::SWCanvas); auto wiper = Wiper::Create(wipe_type); wiper->SetTextures(wipe, wipend); diff --git a/src/gamedata/textures/animations.cpp b/src/gamedata/textures/animations.cpp index 8db6537d9..55dcf060c 100644 --- a/src/gamedata/textures/animations.cpp +++ b/src/gamedata/textures/animations.cpp @@ -709,8 +709,8 @@ void FTextureAnimator::ParseCameraTexture(FScanner &sc) sc.MustGetNumber (); height = sc.Number; FTextureID picnum = TexMan.CheckForTexture (picname, ETextureType::Flat, texflags); - auto canvas = new FCanvasTexture(picname, width, height); - FGameTexture *viewer = MakeGameTexture(canvas, ETextureType::Wall); + auto canvas = new FCanvasTexture(width, height); + FGameTexture *viewer = MakeGameTexture(canvas, picname, ETextureType::Wall); if (picnum.Exists()) { auto oldtex = TexMan.GameTexture(picnum); diff --git a/src/gamedata/textures/buildloader.cpp b/src/gamedata/textures/buildloader.cpp index 37a21eb97..047ad14be 100644 --- a/src/gamedata/textures/buildloader.cpp +++ b/src/gamedata/textures/buildloader.cpp @@ -157,7 +157,7 @@ void AddTiles(const FString& pathprefix, const void* tiles, FRemapTable *remap) if (width <= 0 || height <= 0) continue; FStringf name("%sBTIL%04d", pathprefix.GetChars(), i); - auto tex = MakeGameTexture(new FImageTexture(new FBuildTexture(pathprefix, i, tiledata, remap, width, height, xoffs, yoffs), name), ETextureType::Override); + auto tex = MakeGameTexture(new FImageTexture(new FBuildTexture(pathprefix, i, tiledata, remap, width, height, xoffs, yoffs)), name, ETextureType::Override); texnum = TexMan.AddGameTexture(tex); tiledata += size; diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index c19c3ea3c..55c6b6050 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -77,6 +77,7 @@ static void ParseVavoomSkybox() int facecount=0; int maplump = -1; bool error = false; + FString s = sc.String; FSkyBox * sb = new FSkyBox(sc.String); sb->fliptop = true; sc.MustGetStringName("{"); @@ -93,7 +94,7 @@ static void ParseVavoomSkybox() auto tex = TexMan.FindGameTexture(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny); if (tex == NULL) { - sc.ScriptMessage("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->GetName().GetChars()); + sc.ScriptMessage("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, s.GetChars()); error = true; } sb->faces[facecount] = tex; @@ -103,12 +104,12 @@ static void ParseVavoomSkybox() } if (facecount != 6) { - sc.ScriptError("%s: Skybox definition requires 6 faces", sb->GetName().GetChars()); + sc.ScriptError("%s: Skybox definition requires 6 faces", s.GetChars()); } sb->SetSize(); if (!error) { - TexMan.AddGameTexture(MakeGameTexture(sb, ETextureType::Override)); + TexMan.AddGameTexture(MakeGameTexture(sb, s, ETextureType::Override)); } } } @@ -992,7 +993,6 @@ class GLDefsParser sc.MustGetString(); FString s = sc.String; - s.ToUpper(); FSkyBox * sb = new FSkyBox(s); if (sc.CheckString("fliptop")) { @@ -1010,10 +1010,10 @@ class GLDefsParser } if (facecount != 3 && facecount != 6) { - sc.ScriptError("%s: Skybox definition requires either 3 or 6 faces", sb->GetName().GetChars()); + sc.ScriptError("%s: Skybox definition requires either 3 or 6 faces", s.GetChars()); } sb->SetSize(); - TexMan.AddGameTexture(MakeGameTexture(sb, ETextureType::Override)); + TexMan.AddGameTexture(MakeGameTexture(sb, s, ETextureType::Override)); } //=========================================================================== diff --git a/src/r_data/models/models_voxel.cpp b/src/r_data/models/models_voxel.cpp index d936a2576..cfa65f4b3 100644 --- a/src/r_data/models/models_voxel.cpp +++ b/src/r_data/models/models_voxel.cpp @@ -157,7 +157,7 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) { mVoxel = voxel; mOwningVoxel = owned; - mPalette = TexMan.AddGameTexture(MakeGameTexture(new FImageTexture(new FVoxelTexture(voxel)), ETextureType::Override)); + mPalette = TexMan.AddGameTexture(MakeGameTexture(new FImageTexture(new FVoxelTexture(voxel)), nullptr, ETextureType::Override)); } //=========================================================================== diff --git a/src/r_data/r_canvastexture.cpp b/src/r_data/r_canvastexture.cpp index dd8b91d5a..c12d42e76 100644 --- a/src/r_data/r_canvastexture.cpp +++ b/src/r_data/r_canvastexture.cpp @@ -57,10 +57,11 @@ void FCanvasTextureInfo::Add (AActor *viewpoint, FTextureID picnum, double fov) { return; } - texture = static_cast(TexMan.GetGameTexture(picnum)->GetTexture()); + auto gt = TexMan.GetGameTexture(picnum); + texture = static_cast(gt->GetTexture()); if (!texture->bHasCanvas) { - Printf ("%s is not a valid target for a camera\n", texture->Name.GetChars()); + Printf ("%s is not a valid target for a camera\n", gt->GetName().GetChars()); return; } diff --git a/src/rendering/swrenderer/r_swscene.cpp b/src/rendering/swrenderer/r_swscene.cpp index a34f339ad..25240bcc8 100644 --- a/src/rendering/swrenderer/r_swscene.cpp +++ b/src/rendering/swrenderer/r_swscene.cpp @@ -76,7 +76,7 @@ SWSceneDrawer::SWSceneDrawer() if (!texid.Exists()) { // We need to wrap this in a game texture object to have it managed by the texture manager, even though it will never be used as a material. - auto tex = MakeGameTexture(new FImageTexture(new FSWPaletteTexture, "@@palette@@"), ETextureType::Special); + auto tex = MakeGameTexture(new FImageTexture(new FSWPaletteTexture), "@@palette@@", ETextureType::Special); texid = TexMan.AddGameTexture(tex); } PaletteTexture = TexMan.GetGameTexture(texid)->GetTexture(); @@ -103,7 +103,7 @@ sector_t *SWSceneDrawer::RenderView(player_t *player) { // This manually constructs its own material here. fbtex.reset(); - fbtex.reset(MakeGameTexture(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()), ETextureType::SWCanvas)); + fbtex.reset(MakeGameTexture(new FWrapperTexture(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor()), nullptr, ETextureType::SWCanvas)); GetSystemTexture()->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1); auto mat = FMaterial::ValidateTexture(fbtex.get(), false); mat->AddTextureLayer(PaletteTexture);