- cleaned the texture manager's method interface from FTexture references.

This commit is contained in:
Christoph Oelckers 2020-04-15 23:36:43 +02:00
parent f5d5888c22
commit 7bdef7fe9a
20 changed files with 179 additions and 178 deletions

View file

@ -327,25 +327,25 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
} }
auto orig = pic->GetTexture(); auto orig = pic->GetTexture();
auto tex = new FImageTexture(orig->GetImage(), ""); auto tex = MakeGameTexture(new FImageTexture(orig->GetImage(), "")); // todo - can reuse orig directly later.
tex->SetUseType(ETextureType::FontChar); tex->SetUseType(ETextureType::FontChar);
tex->CopySize(orig); tex->CopySize(pic);
TexMan.AddTexture(tex); TexMan.AddGameTexture(tex);
Chars[i].OriginalPic = tex; Chars[i].OriginalPic = tex;
if (!noTranslate) if (!noTranslate)
{ {
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1(orig->GetImage()), ""); Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1(orig->GetImage()), ""));
Chars[i].TranslatedPic->CopySize(orig); Chars[i].TranslatedPic->CopySize(pic);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar);
TexMan.AddTexture(Chars[i].TranslatedPic); TexMan.AddGameTexture(Chars[i].TranslatedPic);
} }
else else
{ {
Chars[i].TranslatedPic = tex; Chars[i].TranslatedPic = tex;
} }
Chars[i].XMove = Chars[i].TranslatedPic->GetDisplayWidth(); Chars[i].XMove = (int)Chars[i].TranslatedPic->GetDisplayWidth();
} }
else else
{ {
@ -397,7 +397,7 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
auto lump = TexMan.CheckForTexture(entry.name, ETextureType::MiscPatch); auto lump = TexMan.CheckForTexture(entry.name, ETextureType::MiscPatch);
if (lump.isValid()) if (lump.isValid())
{ {
auto tex = TexMan.GetTexture(lump); auto tex = TexMan.GetGameTexture(lump);
int numtex_x = tex->GetTexelWidth() / width; int numtex_x = tex->GetTexelWidth() / width;
int numtex_y = tex->GetTexelHeight() / height; int numtex_y = tex->GetTexelHeight() / height;
int maxinsheet = int(position) + numtex_x * numtex_y - 1; int maxinsheet = int(position) + numtex_x * numtex_y - 1;
@ -410,7 +410,7 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
{ {
part[0].OriginX = -width * x; part[0].OriginX = -width * x;
part[0].OriginY = -height * y; part[0].OriginY = -height * y;
part[0].Image = tex->GetImage(); part[0].Image = tex->GetTexture()->GetImage();
FMultiPatchTexture *image = new FMultiPatchTexture(width, height, part, false, false); FMultiPatchTexture *image = new FMultiPatchTexture(width, height, part, false, false);
FImageTexture *tex = new FImageTexture(image, ""); FImageTexture *tex = new FImageTexture(image, "");
tex->SetUseType(ETextureType::FontChar); tex->SetUseType(ETextureType::FontChar);
@ -425,7 +425,7 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
tex->bWorldPanning = true; tex->bWorldPanning = true;
tex->bNoDecals = false; tex->bNoDecals = false;
tex->SourceLump = -1; // We do not really care. tex->SourceLump = -1; // We do not really care.
TexMan.AddTexture(tex); TexMan.AddGameTexture(MakeGameTexture(tex));
charMap.Insert(int(position) + x + y * numtex_x, reinterpret_cast<FGameTexture*>(tex)); charMap.Insert(int(position) + x + y * numtex_x, reinterpret_cast<FGameTexture*>(tex));
} }
} }
@ -455,14 +455,14 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
auto b = pic->Get8BitPixels(false); auto b = pic->Get8BitPixels(false);
Chars[i].OriginalPic = new FImageTexture(pic->GetImage(), ""); Chars[i].OriginalPic = MakeGameTexture(new FImageTexture(pic->GetImage(), ""));
Chars[i].OriginalPic->SetUseType(ETextureType::FontChar); Chars[i].OriginalPic->SetUseType(ETextureType::FontChar);
Chars[i].OriginalPic->CopySize(pic); Chars[i].OriginalPic->CopySize(*lump);
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1(pic->GetImage()), ""); Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1(pic->GetImage()), ""));
Chars[i].TranslatedPic->CopySize(pic); Chars[i].TranslatedPic->CopySize(*lump);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar);
TexMan.AddTexture(Chars[i].OriginalPic); TexMan.AddGameTexture(Chars[i].OriginalPic);
TexMan.AddTexture(Chars[i].TranslatedPic); TexMan.AddGameTexture(Chars[i].TranslatedPic);
} }
Chars[i].XMove = width; Chars[i].XMove = width;
} }
@ -612,7 +612,7 @@ void FFont::RecordAllTextureColors(uint32_t *usedcolors)
{ {
if (Chars[i].TranslatedPic) if (Chars[i].TranslatedPic)
{ {
FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetImage()); FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetTexture()->GetImage());
if (pic) if (pic)
{ {
// The remap must be temporarily reset here because this can be called on an initialized font. // The remap must be temporarily reset here because this can be called on an initialized font.
@ -999,13 +999,13 @@ FGameTexture *FFont::GetChar (int code, int translation, int *const width, bool
if (redirected) *redirected = redirect; if (redirected) *redirected = redirect;
if (redirect) if (redirect)
{ {
assert(Chars[code].OriginalPic->UseType == ETextureType::FontChar); assert(Chars[code].OriginalPic->GetUseType() == ETextureType::FontChar);
return reinterpret_cast<FGameTexture*>(Chars[code].OriginalPic); return Chars[code].OriginalPic;
} }
} }
if (redirected) *redirected = false; if (redirected) *redirected = false;
assert(Chars[code].TranslatedPic->UseType == ETextureType::FontChar); assert(Chars[code].TranslatedPic->GetUseType() == ETextureType::FontChar);
return reinterpret_cast<FGameTexture*>(Chars[code].TranslatedPic); return Chars[code].TranslatedPic;
} }
//========================================================================== //==========================================================================
@ -1193,7 +1193,7 @@ void FFont::LoadTranslations()
{ {
if (Chars[i].TranslatedPic) if (Chars[i].TranslatedPic)
{ {
FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetImage()); FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetTexture()->GetImage());
if (pic) if (pic)
{ {
pic->SetSourceRemap(nullptr); // Force the FFontChar1 to return the same pixels as the base texture pic->SetSourceRemap(nullptr); // Force the FFontChar1 to return the same pixels as the base texture
@ -1207,7 +1207,7 @@ void FFont::LoadTranslations()
for (unsigned int i = 0; i < count; i++) for (unsigned int i = 0; i < count; i++)
{ {
if(Chars[i].TranslatedPic) if(Chars[i].TranslatedPic)
static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetImage())->SetSourceRemap(PatchRemap); static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetTexture()->GetImage())->SetSourceRemap(PatchRemap);
} }
BuildTranslations (Luminosity.Data(), identity, &TranslationParms[TranslationType][0], ActiveColors, nullptr); BuildTranslations (Luminosity.Data(), identity, &TranslationParms[TranslationType][0], ActiveColors, nullptr);
@ -1283,7 +1283,7 @@ void FFont::FixXMoves()
} }
if (Chars[i].OriginalPic) if (Chars[i].OriginalPic)
{ {
int ofs = Chars[i].OriginalPic->GetDisplayTopOffset(); int ofs = (int)Chars[i].OriginalPic->GetDisplayTopOffset();
if (ofs > Displacement) Displacement = ofs; if (ofs > Displacement) Displacement = ofs;
} }
} }

View file

@ -289,10 +289,10 @@ public:
{ {
auto offset = hexdata.glyphmap[i]; auto offset = hexdata.glyphmap[i];
int size = hexdata.glyphdata[offset] / 16; int size = hexdata.glyphdata[offset] / 16;
Chars[i - FirstChar].TranslatedPic = new FImageTexture(new FHexFontChar (&hexdata.glyphdata[offset+1], size, size * 9, 16)); Chars[i - FirstChar].TranslatedPic = MakeGameTexture(new FImageTexture(new FHexFontChar (&hexdata.glyphdata[offset+1], size, size * 9, 16)));
Chars[i - FirstChar].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i - FirstChar].TranslatedPic->SetUseType(ETextureType::FontChar);
Chars[i - FirstChar].XMove = size * spacing; Chars[i - FirstChar].XMove = size * spacing;
TexMan.AddTexture(Chars[i - FirstChar].TranslatedPic); TexMan.AddGameTexture(Chars[i - FirstChar].TranslatedPic);
} }
else Chars[i - FirstChar].XMove = spacing; else Chars[i - FirstChar].XMove = spacing;
@ -362,10 +362,10 @@ public:
{ {
auto offset = hexdata.glyphmap[i]; auto offset = hexdata.glyphmap[i];
int size = hexdata.glyphdata[offset] / 16; int size = hexdata.glyphdata[offset] / 16;
Chars[i - FirstChar].TranslatedPic = new FImageTexture(new FHexFontChar2(&hexdata.glyphdata[offset + 1], size, 2 + size * 8, 18)); Chars[i - FirstChar].TranslatedPic = MakeGameTexture(new FImageTexture(new FHexFontChar2(&hexdata.glyphdata[offset + 1], size, 2 + size * 8, 18)));
Chars[i - FirstChar].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i - FirstChar].TranslatedPic->SetUseType(ETextureType::FontChar);
Chars[i - FirstChar].XMove = size * spacing; Chars[i - FirstChar].XMove = size * spacing;
TexMan.AddTexture(Chars[i - FirstChar].TranslatedPic); TexMan.AddGameTexture(Chars[i - FirstChar].TranslatedPic);
} }
else Chars[i - FirstChar].XMove = spacing; else Chars[i - FirstChar].XMove = spacing;

View file

@ -167,10 +167,10 @@ FSingleLumpFont::FSingleLumpFont (const char *name, int lump) : FFont(lump)
void FSingleLumpFont::CreateFontFromPic (FTextureID picnum) void FSingleLumpFont::CreateFontFromPic (FTextureID picnum)
{ {
FTexture *pic = TexMan.GetTexture(picnum); auto pic = TexMan.GetGameTexture(picnum);
FontHeight = pic->GetDisplayHeight (); FontHeight = (int)pic->GetDisplayHeight ();
SpaceWidth = pic->GetDisplayWidth (); SpaceWidth = (int)pic->GetDisplayWidth ();
GlobalKerning = 0; GlobalKerning = 0;
FirstChar = LastChar = 'A'; FirstChar = LastChar = 'A';
@ -222,7 +222,7 @@ void FSingleLumpFont::LoadTranslations()
for(unsigned int i = 0;i < count;++i) for(unsigned int i = 0;i < count;++i)
{ {
if(Chars[i].TranslatedPic) if(Chars[i].TranslatedPic)
static_cast<FFontChar2*>(Chars[i].TranslatedPic->GetImage())->SetSourceRemap(PatchRemap); static_cast<FFontChar2*>(Chars[i].TranslatedPic->GetTexture()->GetImage())->SetSourceRemap(PatchRemap);
} }
BuildTranslations (luminosity, useidentity ? identity : nullptr, ranges, ActiveColors, usepalette ? local_palette : nullptr); BuildTranslations (luminosity, useidentity ? identity : nullptr, ranges, ActiveColors, usepalette ? local_palette : nullptr);
@ -353,9 +353,9 @@ void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data)
} }
else else
{ {
Chars[i].TranslatedPic = new FImageTexture(new FFontChar2 (lump, int(data_p - data), widths2[i], FontHeight)); Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar2 (lump, int(data_p - data), widths2[i], FontHeight)));
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar);
TexMan.AddTexture(Chars[i].TranslatedPic); TexMan.AddGameTexture(Chars[i].TranslatedPic);
do do
{ {
int8_t code = *data_p++; int8_t code = *data_p++;
@ -483,15 +483,15 @@ void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data)
{ // Empty character: skip it. { // Empty character: skip it.
continue; continue;
} }
auto tex = new FImageTexture(new FFontChar2(lump, int(chardata + chari + 6 - data), auto tex = MakeGameTexture(new FImageTexture(new FFontChar2(lump, int(chardata + chari + 6 - data),
chardata[chari+1], // width chardata[chari+1], // width
chardata[chari+2], // height chardata[chari+2], // height
-(int8_t)chardata[chari+3], // x offset -(int8_t)chardata[chari+3], // x offset
-(int8_t)chardata[chari+4] // y offset -(int8_t)chardata[chari+4] // y offset
)); )));
tex->SetUseType(ETextureType::FontChar); tex->SetUseType(ETextureType::FontChar);
Chars[chardata[chari] - FirstChar].TranslatedPic = tex; Chars[chardata[chari] - FirstChar].TranslatedPic = tex;
TexMan.AddTexture(tex); TexMan.AddGameTexture(tex);
} }
// If the font did not define a space character, determine a suitable space width now. // If the font did not define a space character, determine a suitable space width now.
@ -556,10 +556,10 @@ void FSingleLumpFont::CheckFON1Chars (double *luminosity)
if(!Chars[i].TranslatedPic) if(!Chars[i].TranslatedPic)
{ {
Chars[i].TranslatedPic = new FImageTexture(new FFontChar2 (Lump, int(data_p - data), SpaceWidth, FontHeight)); Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar2 (Lump, int(data_p - data), SpaceWidth, FontHeight)));
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar);
Chars[i].XMove = SpaceWidth; Chars[i].XMove = SpaceWidth;
TexMan.AddTexture(Chars[i].TranslatedPic); TexMan.AddGameTexture(Chars[i].TranslatedPic);
} }
// Advance to next char's data and count the used colors. // Advance to next char's data and count the used colors.

View file

@ -72,11 +72,11 @@ FSinglePicFont::FSinglePicFont(const char *picname) :
I_FatalError ("%s is not a font or texture", picname); I_FatalError ("%s is not a font or texture", picname);
} }
FTexture *pic = TexMan.GetTexture(picnum); auto pic = TexMan.GetGameTexture(picnum);
FontName = picname; FontName = picname;
FontHeight = pic->GetDisplayHeight(); FontHeight = (int)pic->GetDisplayHeight();
SpaceWidth = pic->GetDisplayWidth(); SpaceWidth = (int)pic->GetDisplayWidth();
GlobalKerning = 0; GlobalKerning = 0;
FirstChar = LastChar = 'A'; FirstChar = LastChar = 'A';
ActiveColors = 0; ActiveColors = 0;

View file

@ -45,7 +45,7 @@
class FSpecialFont : public FFont class FSpecialFont : public FFont
{ {
public: public:
FSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate, int lump, bool donttranslate); FSpecialFont (const char *name, int first, int count, FGameTexture **lumplist, const bool *notranslate, int lump, bool donttranslate);
void LoadTranslations(); void LoadTranslations();
@ -60,13 +60,13 @@ protected:
// //
//========================================================================== //==========================================================================
FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate, int lump, bool donttranslate) FSpecialFont::FSpecialFont (const char *name, int first, int count, FGameTexture **lumplist, const bool *notranslate, int lump, bool donttranslate)
: FFont(lump) : FFont(lump)
{ {
int i; int i;
TArray<FTexture *> charlumps(count, true); TArray<FGameTexture *> charlumps(count, true);
int maxyoffs; int maxyoffs;
FTexture *pic; FGameTexture *pic;
memcpy(this->notranslate, notranslate, 256*sizeof(bool)); memcpy(this->notranslate, notranslate, 256*sizeof(bool));
@ -87,8 +87,8 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l
pic = charlumps[i] = lumplist[i]; pic = charlumps[i] = lumplist[i];
if (pic != nullptr) if (pic != nullptr)
{ {
int height = pic->GetDisplayHeight(); int height = (int)pic->GetDisplayHeight();
int yoffs = pic->GetDisplayTopOffset(); int yoffs = (int)pic->GetDisplayTopOffset();
if (yoffs > maxyoffs) if (yoffs > maxyoffs)
{ {
@ -104,20 +104,20 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l
if (charlumps[i] != nullptr) if (charlumps[i] != nullptr)
{ {
auto pic = charlumps[i]; auto pic = charlumps[i];
Chars[i].OriginalPic = new FImageTexture(pic->GetImage(), ""); Chars[i].OriginalPic = MakeGameTexture(new FImageTexture(pic->GetTexture()->GetImage(), ""));
Chars[i].OriginalPic->SetUseType(ETextureType::FontChar); Chars[i].OriginalPic->SetUseType(ETextureType::FontChar);
Chars[i].OriginalPic->CopySize(pic); Chars[i].OriginalPic->CopySize(pic);
TexMan.AddTexture(Chars[i].OriginalPic); TexMan.AddGameTexture(Chars[i].OriginalPic);
if (!noTranslate) if (!noTranslate)
{ {
Chars[i].TranslatedPic = new FImageTexture(new FFontChar1 (charlumps[i]->GetImage()), ""); Chars[i].TranslatedPic = MakeGameTexture(new FImageTexture(new FFontChar1 (charlumps[i]->GetTexture()->GetImage()), ""));
Chars[i].TranslatedPic->CopySize(charlumps[i]); Chars[i].TranslatedPic->CopySize(charlumps[i]);
Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar); Chars[i].TranslatedPic->SetUseType(ETextureType::FontChar);
TexMan.AddTexture(Chars[i].TranslatedPic); TexMan.AddGameTexture(Chars[i].TranslatedPic);
} }
else Chars[i].TranslatedPic = Chars[i].OriginalPic; else Chars[i].TranslatedPic = Chars[i].OriginalPic;
Chars[i].XMove = Chars[i].TranslatedPic->GetDisplayWidth(); Chars[i].XMove = (int)Chars[i].TranslatedPic->GetDisplayWidth();
} }
else else
{ {
@ -167,7 +167,7 @@ void FSpecialFont::LoadTranslations()
{ {
if (Chars[i].TranslatedPic) if (Chars[i].TranslatedPic)
{ {
FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetImage()); FFontChar1 *pic = static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetTexture()->GetImage());
if (pic) if (pic)
{ {
pic->SetSourceRemap(nullptr); // Force the FFontChar1 to return the same pixels as the base texture pic->SetSourceRemap(nullptr); // Force the FFontChar1 to return the same pixels as the base texture
@ -197,7 +197,7 @@ void FSpecialFont::LoadTranslations()
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
if(Chars[i].TranslatedPic) if(Chars[i].TranslatedPic)
static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetImage())->SetSourceRemap(PatchRemap); static_cast<FFontChar1 *>(Chars[i].TranslatedPic->GetTexture()->GetImage())->SetSourceRemap(PatchRemap);
} }
BuildTranslations(Luminosity.Data(), identity, &TranslationParms[0][0], TotalColors, nullptr, [=](FRemapTable* remap) BuildTranslations(Luminosity.Data(), identity, &TranslationParms[0][0], TotalColors, nullptr, [=](FRemapTable* remap)
@ -217,7 +217,7 @@ void FSpecialFont::LoadTranslations()
ActiveColors = TotalColors; ActiveColors = TotalColors;
} }
FFont *CreateSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate, int lump, bool donttranslate) FFont *CreateSpecialFont (const char *name, int first, int count, FGameTexture **lumplist, const bool *notranslate, int lump, bool donttranslate)
{ {
return new FSpecialFont(name, first, count, lumplist, notranslate, lump, donttranslate); return new FSpecialFont(name, first, count, lumplist, notranslate, lump, donttranslate);
} }

View file

@ -144,7 +144,7 @@ FFont *V_GetFont(const char *name, const char *fontlumpname)
FTextureID picnum = TexMan.CheckForTexture (name, ETextureType::Any); FTextureID picnum = TexMan.CheckForTexture (name, ETextureType::Any);
if (picnum.isValid()) if (picnum.isValid())
{ {
FTexture *tex = TexMan.GetTexture(picnum); auto tex = TexMan.GetGameTexture(picnum);
if (tex && tex->GetSourceLump() >= folderfile) if (tex && tex->GetSourceLump() >= folderfile)
{ {
FFont *CreateSinglePicFont(const char *name); FFont *CreateSinglePicFont(const char *name);
@ -170,7 +170,7 @@ FFont *V_GetFont(const char *name, const char *fontlumpname)
void V_InitCustomFonts() void V_InitCustomFonts()
{ {
FScanner sc; FScanner sc;
FTexture *lumplist[256]; FGameTexture *lumplist[256];
bool notranslate[256]; bool notranslate[256];
bool donttranslate; bool donttranslate;
FString namebuffer, templatebuf; FString namebuffer, templatebuf;
@ -266,12 +266,12 @@ void V_InitCustomFonts()
else else
{ {
if (format == 1) goto wrong; if (format == 1) goto wrong;
FTexture **p = &lumplist[*(unsigned char*)sc.String]; FGameTexture **p = &lumplist[*(unsigned char*)sc.String];
sc.MustGetString(); sc.MustGetString();
FTextureID texid = TexMan.CheckForTexture(sc.String, ETextureType::MiscPatch); FTextureID texid = TexMan.CheckForTexture(sc.String, ETextureType::MiscPatch);
if (texid.Exists()) if (texid.Exists())
{ {
*p = TexMan.GetTexture(texid); *p = TexMan.GetGameTexture(texid);
} }
else if (fileSystem.GetFileContainer(sc.LumpNum) >= fileSystem.GetIwadNum()) else if (fileSystem.GetFileContainer(sc.LumpNum) >= fileSystem.GetIwadNum())
{ {
@ -307,7 +307,7 @@ void V_InitCustomFonts()
} }
if (count > 0) if (count > 0)
{ {
FFont *CreateSpecialFont (const char *name, int first, int count, FTexture **lumplist, const bool *notranslate, int lump, bool donttranslate); FFont *CreateSpecialFont (const char *name, int first, int count, FGameTexture **lumplist, const bool *notranslate, int lump, bool donttranslate);
FFont *fnt = CreateSpecialFont (namebuffer, first, count, &lumplist[first], notranslate, llump, donttranslate); FFont *fnt = CreateSpecialFont (namebuffer, first, count, &lumplist[first], notranslate, llump, donttranslate);
fnt->SetCursor(cursor); fnt->SetCursor(cursor);
fnt->SetKerning(kerning); fnt->SetKerning(kerning);

View file

@ -162,8 +162,8 @@ protected:
bool forceremap = false; bool forceremap = false;
struct CharData struct CharData
{ {
FTexture *TranslatedPic = nullptr; // Texture for use with font translations. FGameTexture *TranslatedPic = nullptr; // Texture for use with font translations.
FTexture *OriginalPic = nullptr; // Texture for use with CR_UNTRANSLATED or font colorization. FGameTexture *OriginalPic = nullptr; // Texture for use with CR_UNTRANSLATED or font colorization.
int XMove = INT_MIN; int XMove = INT_MIN;
}; };
TArray<CharData> Chars; TArray<CharData> Chars;

View file

@ -38,9 +38,11 @@ struct TexPart
class FMultiPatchTexture : public FImageSource class FMultiPatchTexture : public FImageSource
{ {
friend class FTexture; friend class FTexture;
friend class FGameTexture;
public: public:
FMultiPatchTexture(int w, int h, const TArray<TexPart> &parts, bool complex, bool textual); FMultiPatchTexture(int w, int h, const TArray<TexPart> &parts, bool complex, bool textual);
bool SupportRemap0() override; bool SupportRemap0() override;
int GetNumParts() const { return NumParts; }
protected: protected:
int NumParts; int NumParts;

View file

@ -152,7 +152,7 @@ void FMultipatchTextureBuilder::MakeTexture(BuildInfo &buildinfo, ETextureType u
tex->bNoDecals = buildinfo.bNoDecals; tex->bNoDecals = buildinfo.bNoDecals;
tex->SourceLump = buildinfo.DefinitionLump; tex->SourceLump = buildinfo.DefinitionLump;
buildinfo.tex = tex; buildinfo.tex = tex;
TexMan.AddTexture(tex); TexMan.AddGameTexture(MakeGameTexture(tex));
} }
//========================================================================== //==========================================================================
@ -808,18 +808,18 @@ void FMultipatchTextureBuilder::ResolvePatches(BuildInfo &buildinfo)
} }
else else
{ {
FTexture *tex = TexMan.GetTexture(texno); FGameTexture *tex = TexMan.GetGameTexture(texno);
if (tex != nullptr && tex->isValid()) if (tex != nullptr && tex->isValid())
{ {
//We cannot set the image source yet. First all textures need to be resolved. //We cannot set the image source yet. First all textures need to be resolved.
buildinfo.Inits[i].Texture = tex; buildinfo.Inits[i].Texture = tex->GetTexture();
buildinfo.tex->bComplex |= tex->bComplex; buildinfo.tex->bComplex |= tex->GetTexture()->bComplex; // this one's NOT a material property! It must remain on the texture image.
buildinfo.bComplex |= tex->bComplex; buildinfo.bComplex |= tex->GetTexture()->bComplex;
if (buildinfo.Inits[i].UseOffsets) if (buildinfo.Inits[i].UseOffsets)
{ {
buildinfo.Parts[i].OriginX -= tex->GetLeftOffset(0); buildinfo.Parts[i].OriginX -= tex->GetTexelLeftOffset(0);
buildinfo.Parts[i].OriginY -= tex->GetTopOffset(0); buildinfo.Parts[i].OriginY -= tex->GetTexelTopOffset(0);
} }
} }
else else

View file

@ -40,7 +40,7 @@ FSkyBox::FSkyBox(const char *name)
FTextureID texid = TexMan.CheckForTexture(name, ETextureType::Wall); FTextureID texid = TexMan.CheckForTexture(name, ETextureType::Wall);
if (texid.isValid()) if (texid.isValid())
{ {
previous = TexMan.GetTexture(texid); previous = TexMan.GetGameTexture(texid);
} }
else previous = nullptr; else previous = nullptr;
faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5] = nullptr; faces[0]=faces[1]=faces[2]=faces[3]=faces[4]=faces[5] = nullptr;
@ -58,9 +58,9 @@ FSkyBox::FSkyBox(const char *name)
void FSkyBox::SetSize() void FSkyBox::SetSize()
{ {
if (!previous && faces[0]) previous = faces[0]; if (!previous && faces[0]) previous = faces[0];
if (previous && previous->GetImage()) if (previous && previous->GetTexture()->GetImage())
{ {
SetImage(previous->GetImage()); SetImage(previous->GetTexture()->GetImage());
SetFromImage(); SetFromImage();
} }
} }

View file

@ -119,7 +119,6 @@ FTexture::FTexture (const char *name, int lumpnum)
bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bFullNameTexture(false), bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bFullNameTexture(false),
Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0) Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0)
{ {
tempGameTexture = reinterpret_cast<FGameTexture*>(this);
bBrightmapChecked = false; bBrightmapChecked = false;
bGlowing = false; bGlowing = false;
bAutoGlowing = false; bAutoGlowing = false;
@ -188,14 +187,16 @@ FBitmap FTexture::GetBgraBitmap(const PalEntry *remap, int *ptrans)
// //
//========================================================================== //==========================================================================
FTexture *FTexture::GetRawTexture() FGameTexture *FGameTexture::GetRawTexture()
{ {
if (OffsetLess) return OffsetLess; auto tex = GetTexture();
if (tex->OffsetLess) return tex->OffsetLess;
// Reject anything that cannot have been a single-patch multipatch texture in vanilla. // Reject anything that cannot have been a single-patch multipatch texture in vanilla.
auto image = static_cast<FMultiPatchTexture *>(GetImage()); auto image = static_cast<FMultiPatchTexture *>(tex->GetImage());
if (bMultiPatch != 1 || UseType != ETextureType::Wall || Scale.X != 1 || Scale.Y != 1 || bWorldPanning || image == nullptr || image->NumParts != 1 || _TopOffset[0] == 0) if (tex->bMultiPatch != 1 || GetUseType() != ETextureType::Wall || tex->Scale.X != 1 || tex->Scale.Y != 1 ||
useWorldPanning() || image == nullptr || image->GetNumParts() != 1 || tex->_TopOffset[0] == 0)
{ {
OffsetLess = this; tex->OffsetLess = this;
return this; return this;
} }
// Set up a new texture that directly references the underlying patch. // Set up a new texture that directly references the underlying patch.
@ -203,16 +204,17 @@ FTexture *FTexture::GetRawTexture()
FImageSource *source = image->Parts[0].Image; FImageSource *source = image->Parts[0].Image;
// Size must match for this to work as intended // Size must match for this to work as intended
if (source->GetWidth() != Width || source->GetHeight() != Height) if (source->GetWidth() != GetTexelWidth() || source->GetHeight() != GetTexelHeight())
{ {
OffsetLess = this; tex->OffsetLess = this;
return this; return this;
} }
OffsetLess = new FImageTexture(source, ""); tex->OffsetLess = MakeGameTexture(new FImageTexture(source, ""));
TexMan.AddTexture(OffsetLess); // todo: This must also copy all layers from the base texture.
return OffsetLess; TexMan.AddGameTexture(tex->OffsetLess);
return tex->OffsetLess;
} }
//========================================================================== //==========================================================================
@ -221,22 +223,23 @@ FTexture *FTexture::GetRawTexture()
// //
//========================================================================== //==========================================================================
FTexture* FTexture::GetFrontSkyLayer() FGameTexture* FGameTexture::GetFrontSkyLayer()
{ {
if (FrontSkyLayer) return FrontSkyLayer; auto tex = GetTexture();
if (tex->FrontSkyLayer) return tex->FrontSkyLayer;
// Reject anything that cannot have been a front layer for the sky in Hexen. // Reject anything that cannot have been a front layer for the sky in Hexen.
auto image = GetImage(); auto image = tex->GetImage();
if (image == nullptr || !image->SupportRemap0() || UseType != ETextureType::Wall || Scale.X != 1 || Scale.Y != 1 || bWorldPanning || _TopOffset[0] != 0 || if (image == nullptr || !image->SupportRemap0() || GetUseType() != ETextureType::Wall || tex->Scale.X != 1 || tex->Scale.Y != 1 || useWorldPanning() || tex->_TopOffset[0] != 0 ||
image->GetWidth() != GetTexelWidth() || image->GetHeight() != GetTexelHeight()) image->GetWidth() != GetTexelWidth() || image->GetHeight() != GetTexelHeight())
{ {
FrontSkyLayer = this; tex->FrontSkyLayer = this;
return this; return this;
} }
FrontSkyLayer = new FImageTexture(image, ""); tex->FrontSkyLayer = MakeGameTexture(new FImageTexture(image, ""));
TexMan.AddTexture(FrontSkyLayer); TexMan.AddGameTexture(tex->FrontSkyLayer);
FrontSkyLayer->bNoRemap0 = true; tex->FrontSkyLayer->GetTexture()->bNoRemap0 = true;
return FrontSkyLayer; return tex->FrontSkyLayer;
} }
@ -424,7 +427,7 @@ void FTexture::CreateDefaultBrightmap()
DPrintf(DMSG_NOTIFY, "brightmap created for texture '%s'\n", Name.GetChars()); DPrintf(DMSG_NOTIFY, "brightmap created for texture '%s'\n", Name.GetChars());
Brightmap = CreateBrightmapTexture(static_cast<FImageTexture*>(this)->GetImage()); Brightmap = CreateBrightmapTexture(static_cast<FImageTexture*>(this)->GetImage());
bBrightmapChecked = true; bBrightmapChecked = true;
TexMan.AddTexture(Brightmap); TexMan.AddGameTexture(MakeGameTexture(Brightmap));
return; return;
} }
} }

View file

@ -229,12 +229,12 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset
if (tex == NO_TEXTURE) return FTextureID(-1); if (tex == NO_TEXTURE) return FTextureID(-1);
if (tex != NULL) return tex->GetID(); 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. 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 = reinterpret_cast<FGameTexture*>(FTexture::CreateTexture("", lump, ETextureType::Override)); tex = MakeGameTexture(FTexture::CreateTexture("", lump, ETextureType::Override));
if (tex != NULL) if (tex != NULL)
{ {
tex->AddAutoMaterials(); tex->AddAutoMaterials();
fileSystem.SetLinkedTexture(lump, tex); fileSystem.SetLinkedTexture(lump, tex);
return AddTexture(tex->GetTexture()); return AddGameTexture(tex);
} }
else else
{ {
@ -375,7 +375,7 @@ bool FTextureManager::OkForLocalization(FTextureID texnum, const char *substitut
// //
//========================================================================== //==========================================================================
FTextureID FTextureManager::AddTexture (FTexture *texture) FTextureID FTextureManager::AddGameTexture (FGameTexture *texture)
{ {
int bucket; int bucket;
int hash; int hash;
@ -385,9 +385,9 @@ FTextureID FTextureManager::AddTexture (FTexture *texture)
// Later textures take precedence over earlier ones // Later textures take precedence over earlier ones
// Textures without name can't be looked for // Textures without name can't be looked for
if (texture->Name[0] != '\0') if (texture->GetName().IsNotEmpty())
{ {
bucket = int(MakeKey (texture->Name) % HASH_SIZE); bucket = int(MakeKey (texture->GetName()) % HASH_SIZE);
hash = HashFirst[bucket]; hash = HashFirst[bucket];
} }
else else
@ -400,7 +400,7 @@ FTextureID FTextureManager::AddTexture (FTexture *texture)
int trans = Textures.Push (hasher); int trans = Textures.Push (hasher);
Translation.Push (trans); Translation.Push (trans);
if (bucket >= 0) HashFirst[bucket] = trans; if (bucket >= 0) HashFirst[bucket] = trans;
return (texture->id = FTextureID(trans)); return (texture->GetTexture()->id = FTextureID(trans));
} }
//========================================================================== //==========================================================================
@ -417,9 +417,9 @@ FTextureID FTextureManager::CreateTexture (int lumpnum, ETextureType usetype)
{ {
FString str; FString str;
fileSystem.GetFileShortName(str, lumpnum); fileSystem.GetFileShortName(str, lumpnum);
FTexture *out = FTexture::CreateTexture(str, lumpnum, usetype); auto out = MakeGameTexture(FTexture::CreateTexture(str, lumpnum, usetype));
if (out != NULL) return AddTexture (out); if (out != NULL) return AddGameTexture (out);
else else
{ {
Printf (TEXTCOLOR_ORANGE "Invalid data encountered for texture %s\n", fileSystem.GetFileFullPath(lumpnum).GetChars()); Printf (TEXTCOLOR_ORANGE "Invalid data encountered for texture %s\n", fileSystem.GetFileFullPath(lumpnum).GetChars());
@ -435,7 +435,7 @@ FTextureID FTextureManager::CreateTexture (int lumpnum, ETextureType usetype)
// //
//========================================================================== //==========================================================================
void FTextureManager::ReplaceTexture (FTextureID picnum, FTexture *newtexture, bool free) void FTextureManager::ReplaceTexture (FTextureID picnum, FGameTexture *newtexture, bool free)
{ {
int index = picnum.GetIndex(); int index = picnum.GetIndex();
if (unsigned(index) >= Textures.Size()) if (unsigned(index) >= Textures.Size())
@ -443,12 +443,12 @@ void FTextureManager::ReplaceTexture (FTextureID picnum, FTexture *newtexture, b
auto oldtexture = Textures[index].Texture; auto oldtexture = Textures[index].Texture;
newtexture->Name = oldtexture->GetName(); newtexture->GetTexture()->Name = oldtexture->GetName();
newtexture->UseType = oldtexture->GetUseType(); newtexture->SetUseType(oldtexture->GetUseType());
Textures[index].Texture = reinterpret_cast<FGameTexture*>(newtexture); Textures[index].Texture = reinterpret_cast<FGameTexture*>(newtexture);
newtexture->id = oldtexture->GetID(); newtexture->GetTexture()->id = oldtexture->GetID();
oldtexture->GetTexture()->Name = ""; oldtexture->GetTexture()->Name = "";
AddTexture(oldtexture->GetTexture()); AddGameTexture(oldtexture);
} }
//========================================================================== //==========================================================================
@ -557,11 +557,11 @@ void FTextureManager::AddHiresTextures (int wadnum)
if (amount == 0) if (amount == 0)
{ {
// A texture with this name does not yet exist // A texture with this name does not yet exist
FTexture * newtex = FTexture::CreateTexture (Name, firsttx, ETextureType::Any); auto newtex = MakeGameTexture(FTexture::CreateTexture (Name, firsttx, ETextureType::Any));
if (newtex != NULL) if (newtex != NULL)
{ {
newtex->UseType=ETextureType::Override; newtex->SetUseType(ETextureType::Override);
AddTexture(newtex); AddGameTexture(newtex);
} }
} }
else else
@ -575,12 +575,12 @@ void FTextureManager::AddHiresTextures (int wadnum)
// Replace the entire texture and adjust the scaling and offset factors. // Replace the entire texture and adjust the scaling and offset factors.
newtex->bWorldPanning = true; newtex->bWorldPanning = true;
newtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight()); newtex->SetDisplaySize((int)oldtex->GetDisplayWidth(), (int)oldtex->GetDisplayHeight());
newtex->_LeftOffset[0] = int(oldtex->GetDisplayLeftOffset(0) * newtex->Scale.X); newtex->_LeftOffset[0] = int(oldtex->GetDisplayLeftOffset(0) * newtex->Scale.X);
newtex->_LeftOffset[1] = int(oldtex->GetDisplayLeftOffset(1) * newtex->Scale.X); newtex->_LeftOffset[1] = int(oldtex->GetDisplayLeftOffset(1) * newtex->Scale.X);
newtex->_TopOffset[0] = int(oldtex->GetDisplayTopOffset(0) * newtex->Scale.Y); newtex->_TopOffset[0] = int(oldtex->GetDisplayTopOffset(0) * newtex->Scale.Y);
newtex->_TopOffset[1] = int(oldtex->GetDisplayTopOffset(1) * newtex->Scale.Y); newtex->_TopOffset[1] = int(oldtex->GetDisplayTopOffset(1) * newtex->Scale.Y);
ReplaceTexture(tlist[i], newtex, true); ReplaceTexture(tlist[i], MakeGameTexture(newtex), true);
} }
} }
} }
@ -672,12 +672,12 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build
{ {
// Replace the entire texture and adjust the scaling and offset factors. // Replace the entire texture and adjust the scaling and offset factors.
newtex->bWorldPanning = true; newtex->bWorldPanning = true;
newtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight()); newtex->SetDisplaySize((int)oldtex->GetDisplayWidth(), (int)oldtex->GetDisplayHeight());
newtex->_LeftOffset[0] = int(oldtex->GetDisplayLeftOffset(0) * newtex->Scale.X); newtex->_LeftOffset[0] = int(oldtex->GetDisplayLeftOffset(0) * newtex->Scale.X);
newtex->_LeftOffset[1] = int(oldtex->GetDisplayLeftOffset(1) * newtex->Scale.X); newtex->_LeftOffset[1] = int(oldtex->GetDisplayLeftOffset(1) * newtex->Scale.X);
newtex->_TopOffset[0] = int(oldtex->GetDisplayTopOffset(0) * newtex->Scale.Y); newtex->_TopOffset[0] = int(oldtex->GetDisplayTopOffset(0) * newtex->Scale.Y);
newtex->_TopOffset[1] = int(oldtex->GetDisplayTopOffset(1) * newtex->Scale.Y); newtex->_TopOffset[1] = int(oldtex->GetDisplayTopOffset(1) * newtex->Scale.Y);
ReplaceTexture(tlist[i], newtex, true); ReplaceTexture(tlist[i], MakeGameTexture(newtex), true);
} }
} }
} }
@ -706,21 +706,21 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build
if (lumpnum>=0) if (lumpnum>=0)
{ {
FTexture *newtex = FTexture::CreateTexture(src, lumpnum, ETextureType::Override); auto newtex = MakeGameTexture(FTexture::CreateTexture(src, lumpnum, ETextureType::Override));
if (newtex != NULL) if (newtex != NULL)
{ {
// Replace the entire texture and adjust the scaling and offset factors. // Replace the entire texture and adjust the scaling and offset factors.
newtex->bWorldPanning = true; newtex->SetWorldPanning(true);
newtex->SetDisplaySize(width, height); newtex->SetDisplaySize((float)width, (float)height);
FTextureID oldtex = TexMan.CheckForTexture(src, ETextureType::MiscPatch); FTextureID oldtex = TexMan.CheckForTexture(src, ETextureType::MiscPatch);
if (oldtex.isValid()) if (oldtex.isValid())
{ {
ReplaceTexture(oldtex, newtex, true); ReplaceTexture(oldtex, newtex, true);
newtex->UseType = ETextureType::Override; newtex->SetUseType(ETextureType::Override);
} }
else AddTexture(newtex); else AddGameTexture(newtex);
} }
} }
} }
@ -926,11 +926,11 @@ void FTextureManager::AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &b
// Try to create a texture from this lump and add it. // Try to create a texture from this lump and add it.
// Unfortunately we have to look at everything that comes through here... // Unfortunately we have to look at everything that comes through here...
FTexture *out = FTexture::CreateTexture(Name, i, skin ? ETextureType::SkinGraphic : ETextureType::MiscPatch); auto out = MakeGameTexture(FTexture::CreateTexture(Name, i, skin ? ETextureType::SkinGraphic : ETextureType::MiscPatch));
if (out != NULL) if (out != NULL)
{ {
AddTexture (out); AddGameTexture (out);
} }
} }
@ -984,7 +984,7 @@ void FTextureManager::SortTexturesByType(int start, int end)
{ {
if (newtextures[j] != NULL && newtextures[j]->GetUseType() == texturetypes[i]) if (newtextures[j] != NULL && newtextures[j]->GetUseType() == texturetypes[i])
{ {
AddTexture(newtextures[j]->GetTexture()); AddGameTexture(newtextures[j]);
newtextures[j] = NULL; newtextures[j] = NULL;
} }
} }
@ -995,7 +995,7 @@ void FTextureManager::SortTexturesByType(int start, int end)
if (newtextures[j] != NULL) if (newtextures[j] != NULL)
{ {
Printf("Texture %s has unknown type!\n", newtextures[j]->GetName().GetChars()); Printf("Texture %s has unknown type!\n", newtextures[j]->GetName().GetChars());
AddTexture(newtextures[j]->GetTexture()); AddGameTexture(newtextures[j]);
} }
} }
} }
@ -1033,8 +1033,8 @@ void FTextureManager::AddLocalizedVariants()
FTextureID tex = CheckForTexture(entry.name, ETextureType::MiscPatch); FTextureID tex = CheckForTexture(entry.name, ETextureType::MiscPatch);
if (tex.isValid()) if (tex.isValid())
{ {
FTexture *otex = GetTexture(origTex); auto otex = GetGameTexture(origTex);
FTexture *ntex = GetTexture(tex); auto ntex = GetGameTexture(tex);
if (otex->GetDisplayWidth() != ntex->GetDisplayWidth() || otex->GetDisplayHeight() != ntex->GetDisplayHeight()) if (otex->GetDisplayWidth() != ntex->GetDisplayWidth() || otex->GetDisplayHeight() != ntex->GetDisplayHeight())
{ {
Printf("Localized texture %s must be the same size as the one it replaces\n", entry.name); Printf("Localized texture %s must be the same size as the one it replaces\n", entry.name);
@ -1093,18 +1093,18 @@ void FTextureManager::Init(void (*progressFunc_)(), void (*checkForHacks)(BuildI
//if (BuildTileFiles.Size() == 0) CountBuildTiles (); //if (BuildTileFiles.Size() == 0) CountBuildTiles ();
// Texture 0 is a dummy texture used to indicate "no texture" // Texture 0 is a dummy texture used to indicate "no texture"
auto nulltex = new FImageTexture(nullptr, ""); auto nulltex = MakeGameTexture(new FImageTexture(nullptr, ""));
nulltex->SetUseType(ETextureType::Null); nulltex->SetUseType(ETextureType::Null);
AddTexture (nulltex); 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. // 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 = new FImageTexture(CreateEmptyTexture(), ""); auto emptytex = MakeGameTexture(new FImageTexture(CreateEmptyTexture(), ""));
emptytex->SetSize(1, 1); emptytex->SetSize(1, 1);
AddTexture(emptytex); AddGameTexture(emptytex);
// some special textures used in the game. // some special textures used in the game.
AddTexture(CreateShaderTexture(false, false)); AddGameTexture(MakeGameTexture(CreateShaderTexture(false, false)));
AddTexture(CreateShaderTexture(false, true)); AddGameTexture(MakeGameTexture(CreateShaderTexture(false, true)));
AddTexture(CreateShaderTexture(true, false)); AddGameTexture(MakeGameTexture(CreateShaderTexture(true, false)));
AddTexture(CreateShaderTexture(true, true)); AddGameTexture(MakeGameTexture(CreateShaderTexture(true, true)));
int wadcnt = fileSystem.GetNumWads(); int wadcnt = fileSystem.GetNumWads();
@ -1170,10 +1170,10 @@ void FTextureManager::InitPalettedVersions()
} }
if (pic1.isValid() && pic2.isValid()) if (pic1.isValid() && pic2.isValid())
{ {
FTexture *owner = GetTexture(pic1); auto owner = GetGameTexture(pic1);
FTexture *owned = GetTexture(pic2); auto owned = GetGameTexture(pic2);
if (owner && owned) owner->PalVersion = owned; if (owner && owned) owner->GetTexture()->PalVersion = owned;
} }
} }
} }
@ -1320,7 +1320,7 @@ void FTextureManager::AdjustSpriteOffsets()
fileSystem.GetFileShortName(str, i); fileSystem.GetFileShortName(str, i);
str[8] = 0; str[8] = 0;
FTextureID texid = TexMan.CheckForTexture(str, ETextureType::Sprite, 0); FTextureID texid = TexMan.CheckForTexture(str, ETextureType::Sprite, 0);
if (texid.isValid() && fileSystem.GetFileContainer(GetTexture(texid)->SourceLump) > fileSystem.GetMaxIwadNum()) if (texid.isValid() && fileSystem.GetFileContainer(GetGameTexture(texid)->GetSourceLump()) > fileSystem.GetMaxIwadNum())
{ {
// This texture has been replaced by some PWAD. // This texture has been replaced by some PWAD.
memcpy(&sprid, str, 4); memcpy(&sprid, str, 4);
@ -1355,7 +1355,7 @@ void FTextureManager::AdjustSpriteOffsets()
} }
if (texno.isValid()) if (texno.isValid())
{ {
FTexture * tex = GetTexture(texno); auto tex = GetGameTexture(texno);
int lumpnum = tex->GetSourceLump(); int lumpnum = tex->GetSourceLump();
// We only want to change texture offsets for sprites in the IWAD or the file this lump originated from. // We only want to change texture offsets for sprites in the IWAD or the file this lump originated from.
@ -1366,11 +1366,11 @@ void FTextureManager::AdjustSpriteOffsets()
{ {
if (wadno >= fileSystem.GetIwadNum() && wadno <= fileSystem.GetMaxIwadNum() && !forced && iwadonly) if (wadno >= fileSystem.GetIwadNum() && wadno <= fileSystem.GetMaxIwadNum() && !forced && iwadonly)
{ {
memcpy(&sprid, &tex->Name[0], 4); memcpy(&sprid, tex->GetName().GetChars(), 4);
if (donotprocess.CheckKey(sprid)) continue; // do not alter sprites that only get partially replaced. if (donotprocess.CheckKey(sprid)) continue; // do not alter sprites that only get partially replaced.
} }
tex->_LeftOffset[1] = x; tex->GetTexture()->_LeftOffset[1] = x;
tex->_TopOffset[1] = y; tex->GetTexture()->_TopOffset[1] = y;
} }
} }
} }

View file

@ -8,7 +8,6 @@
#include "name.h" #include "name.h"
class FxAddSub; class FxAddSub;
class FTexture;
struct BuildInfo; struct BuildInfo;
int PalCheck(int tex); int PalCheck(int tex);
@ -39,11 +38,6 @@ public:
return InternalGetTexture(texnum.GetIndex(), animate, true); return InternalGetTexture(texnum.GetIndex(), animate, true);
} }
FTexture *GetTexture(FTextureID texnum, bool animate = false)
{
return InternalGetTexture(texnum.GetIndex(), animate, true)->GetTexture();
}
FGameTexture* GetGameTexture(FTextureID texnum, bool animate = false) FGameTexture* GetGameTexture(FTextureID texnum, bool animate = false)
{ {
return InternalGetTexture(texnum.GetIndex(), animate, true); return InternalGetTexture(texnum.GetIndex(), animate, true);
@ -97,7 +91,7 @@ public:
void AddLocalizedVariants(); void AddLocalizedVariants();
FTextureID CreateTexture (int lumpnum, ETextureType usetype=ETextureType::Any); // Also calls AddTexture FTextureID CreateTexture (int lumpnum, ETextureType usetype=ETextureType::Any); // Also calls AddTexture
FTextureID AddTexture (FTexture *texture); FTextureID AddGameTexture(FGameTexture* texture);
FTextureID GetDefaultTexture() const { return DefaultTexture; } FTextureID GetDefaultTexture() const { return DefaultTexture; }
void LoadTextureX(int wadnum, FMultipatchTextureBuilder &build); void LoadTextureX(int wadnum, FMultipatchTextureBuilder &build);
@ -105,7 +99,7 @@ public:
void Init(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo &)); void Init(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo &));
void DeleteAll(); void DeleteAll();
void ReplaceTexture (FTextureID picnum, FTexture *newtexture, bool free); void ReplaceTexture (FTextureID picnum, FGameTexture *newtexture, bool free);
int NumTextures () const { return (int)Textures.Size(); } int NumTextures () const { return (int)Textures.Size(); }
@ -142,7 +136,6 @@ public:
return BuildTileData.Last(); return BuildTileData.Last();
} }
FTexture* Texture(FTextureID id) { return Textures[id.GetIndex()].Texture->GetTexture(); }
FGameTexture* GameTexture(FTextureID id) { return Textures[id.GetIndex()].Texture; } FGameTexture* GameTexture(FTextureID id) { return Textures[id.GetIndex()].Texture; }
void SetTranslation(FTextureID fromtexnum, FTextureID totexnum); void SetTranslation(FTextureID fromtexnum, FTextureID totexnum);
@ -184,3 +177,8 @@ public:
}; };
extern FTextureManager TexMan; extern FTextureManager TexMan;
inline FGameTexture* MakeGameTexture(FTexture* tex)
{
return reinterpret_cast<FGameTexture*>(tex);
}

View file

@ -273,7 +273,6 @@ public:
int GetDisplayTopOffset() { return GetScaledTopOffset(0); } int GetDisplayTopOffset() { return GetScaledTopOffset(0); }
double GetDisplayLeftOffsetDouble(int adjusted = 0) { return _LeftOffset[adjusted] / Scale.X; } double GetDisplayLeftOffsetDouble(int adjusted = 0) { return _LeftOffset[adjusted] / Scale.X; }
double GetDisplayTopOffsetDouble(int adjusted = 0) { return _TopOffset[adjusted] / Scale.Y; } double GetDisplayTopOffsetDouble(int adjusted = 0) { return _TopOffset[adjusted] / Scale.Y; }
FTexture* GetFrontSkyLayer();
int GetTexelWidth() { return Width; } int GetTexelWidth() { return Width; }
int GetTexelHeight() { return Height; } int GetTexelHeight() { return Height; }
@ -303,7 +302,6 @@ public:
int GetSkyOffset() const { return SkyOffset; } int GetSkyOffset() const { return SkyOffset; }
FTextureID GetID() const { return id; } FTextureID GetID() const { return id; }
PalEntry GetSkyCapColor(bool bottom); PalEntry GetSkyCapColor(bool bottom);
FTexture *GetRawTexture();
virtual int GetSourceLump() { return SourceLump; } // needed by the scripted GetName method. virtual int GetSourceLump() { return SourceLump; } // needed by the scripted GetName method.
void GetGlowColor(float *data); void GetGlowColor(float *data);
bool isGlowing() const { return bGlowing; } bool isGlowing() const { return bGlowing; }
@ -378,12 +376,12 @@ protected:
// 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.
// Offset-less version for COMPATF_MASKEDMIDTEX // Offset-less version for COMPATF_MASKEDMIDTEX
FTexture *OffsetLess = nullptr; FGameTexture *OffsetLess = nullptr;
// Front sky layer variant where color 0 is transparent // Front sky layer variant where color 0 is transparent
FTexture* FrontSkyLayer = nullptr; FGameTexture* FrontSkyLayer = nullptr;
public: public:
// Paletted variant // Paletted variant
FTexture *PalVersion = nullptr; FGameTexture *PalVersion = nullptr;
// Material layers // Material layers
FTexture *Brightmap = nullptr; FTexture *Brightmap = nullptr;
FTexture* Detailmap = nullptr; FTexture* Detailmap = nullptr;
@ -483,7 +481,7 @@ public:
{ {
return Material[num]; return Material[num];
} }
FTexture* GetPalVersion() FGameTexture* GetPalVersion()
{ {
return PalVersion; return PalVersion;
} }
@ -631,8 +629,8 @@ class FSkyBox : public FImageTexture
{ {
public: public:
FTexture* previous; FGameTexture* previous;
FTexture* faces[6]; FGameTexture* faces[6]; // the faces need to be full materials as they can have all supported effects.
bool fliptop; bool fliptop;
FSkyBox(const char* name); FSkyBox(const char* name);
@ -724,9 +722,9 @@ public:
} }
// These substitutions must be done on the material level because their sizes can differ. Substitution must happen before any coordinate calculations take place. // These substitutions must be done on the material level because their sizes can differ. Substitution must happen before any coordinate calculations take place.
FGameTexture* GetPalVersion() { return reinterpret_cast<FGameTexture*>(wrapped.GetPalVersion()); } FGameTexture* GetPalVersion() { return wrapped.GetPalVersion(); }
FGameTexture* GetRawTexture() { return reinterpret_cast<FGameTexture*>(wrapped.GetRawTexture()); } FGameTexture* GetRawTexture();
FGameTexture* GetFrontSkyLayer() { return reinterpret_cast<FGameTexture*>(wrapped.GetFrontSkyLayer()); } FGameTexture* GetFrontSkyLayer();
// Glowing is a pure material property that should not filter down to the actual texture objects. // Glowing is a pure material property that should not filter down to the actual texture objects.
void GetGlowColor(float* data) { wrapped.GetGlowColor(data); } void GetGlowColor(float* data) { wrapped.GetGlowColor(data); }

View file

@ -709,14 +709,14 @@ void FTextureAnimator::ParseCameraTexture(FScanner &sc)
sc.MustGetNumber (); sc.MustGetNumber ();
height = sc.Number; height = sc.Number;
FTextureID picnum = TexMan.CheckForTexture (picname, ETextureType::Flat, texflags); FTextureID picnum = TexMan.CheckForTexture (picname, ETextureType::Flat, texflags);
FGameTexture *viewer = reinterpret_cast<FGameTexture*>(new FCanvasTexture (picname, width, height)); FGameTexture *viewer = MakeGameTexture(new FCanvasTexture (picname, width, height));
if (picnum.Exists()) if (picnum.Exists())
{ {
auto oldtex = TexMan.GameTexture(picnum); auto oldtex = TexMan.GameTexture(picnum);
fitwidth = oldtex->GetDisplayWidth (); fitwidth = oldtex->GetDisplayWidth ();
fitheight = oldtex->GetDisplayHeight (); fitheight = oldtex->GetDisplayHeight ();
viewer->SetUseType(oldtex->GetUseType()); viewer->SetUseType(oldtex->GetUseType());
TexMan.ReplaceTexture (picnum, viewer->GetTexture(), true); TexMan.ReplaceTexture (picnum, viewer, true);
} }
else else
{ {
@ -724,7 +724,7 @@ void FTextureAnimator::ParseCameraTexture(FScanner &sc)
fitheight = height; fitheight = height;
// [GRB] No need for oldtex // [GRB] No need for oldtex
viewer->SetUseType(ETextureType::Wall); viewer->SetUseType(ETextureType::Wall);
TexMan.AddTexture (viewer->GetTexture()); TexMan.AddGameTexture (viewer);
} }
if (sc.GetString()) if (sc.GetString())
{ {

View file

@ -153,13 +153,12 @@ void AddTiles(const FString& pathprefix, const void* tiles, FRemapTable *remap)
int yoffs = (int8_t)((anm >> 16) & 255) + height / 2; int yoffs = (int8_t)((anm >> 16) & 255) + height / 2;
int size = width * height; int size = width * height;
FTextureID texnum; FTextureID texnum;
FTexture* tex;
if (width <= 0 || height <= 0) continue; if (width <= 0 || height <= 0) continue;
FStringf name("%sBTIL%04d", pathprefix.GetChars(), i); FStringf name("%sBTIL%04d", pathprefix.GetChars(), i);
tex = new FImageTexture(new FBuildTexture(pathprefix, i, tiledata, remap, width, height, xoffs, yoffs), name); auto tex = MakeGameTexture(new FImageTexture(new FBuildTexture(pathprefix, i, tiledata, remap, width, height, xoffs, yoffs), name));
texnum = TexMan.AddTexture(tex); texnum = TexMan.AddGameTexture(tex);
tiledata += size; tiledata += size;
tex->SetUseType(ETextureType::Override); tex->SetUseType(ETextureType::Override);

View file

@ -96,7 +96,7 @@ static void ParseVavoomSkybox()
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, sb->GetName().GetChars());
error = true; error = true;
} }
sb->faces[facecount] = tex->GetTexture(); sb->faces[facecount] = tex;
sc.MustGetStringName("}"); sc.MustGetStringName("}");
} }
facecount++; facecount++;
@ -108,7 +108,7 @@ static void ParseVavoomSkybox()
sb->SetSize(); sb->SetSize();
if (!error) if (!error)
{ {
TexMan.AddTexture(sb); TexMan.AddGameTexture(MakeGameTexture(sb));
} }
} }
} }
@ -1004,7 +1004,7 @@ class GLDefsParser
sc.MustGetString(); sc.MustGetString();
if (facecount<6) if (facecount<6)
{ {
sb->faces[facecount] = TexMan.GetTexture(TexMan.GetTextureID(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_Overridable)); sb->faces[facecount] = TexMan.GetGameTexture(TexMan.GetTextureID(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_Overridable));
} }
facecount++; facecount++;
} }
@ -1013,7 +1013,7 @@ class GLDefsParser
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", sb->GetName().GetChars());
} }
sb->SetSize(); sb->SetSize();
TexMan.AddTexture(sb); TexMan.AddGameTexture(MakeGameTexture(sb));
} }
//=========================================================================== //===========================================================================

View file

@ -157,7 +157,7 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned)
{ {
mVoxel = voxel; mVoxel = voxel;
mOwningVoxel = owned; mOwningVoxel = owned;
mPalette = TexMan.AddTexture(new FImageTexture(new FVoxelTexture(voxel))); mPalette = TexMan.AddGameTexture(MakeGameTexture(new FImageTexture(new FVoxelTexture(voxel))));
} }
//=========================================================================== //===========================================================================

View file

@ -57,7 +57,7 @@ void FCanvasTextureInfo::Add (AActor *viewpoint, FTextureID picnum, double fov)
{ {
return; return;
} }
texture = static_cast<FCanvasTexture *>(TexMan.GetTexture(picnum)); texture = static_cast<FCanvasTexture *>(TexMan.GetGameTexture(picnum)->GetTexture());
if (!texture->bHasCanvas) 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", texture->Name.GetChars());
@ -101,8 +101,8 @@ void SetCameraToTexture(AActor *viewpoint, const FString &texturename, double fo
if (textureid.isValid()) if (textureid.isValid())
{ {
// Only proceed if the texture actually has a canvas. // Only proceed if the texture actually has a canvas.
FTexture *tex = TexMan.GetTexture(textureid); auto tex = TexMan.GetGameTexture(textureid);
if (tex && tex->isCanvas()) if (tex && tex->isHardwareCanvas()) // Q: how to deal with the software renderer here?
{ {
viewpoint->Level->canvasTextureInfo.Add(viewpoint, textureid, fov); viewpoint->Level->canvasTextureInfo.Add(viewpoint, textureid, fov);
} }

View file

@ -75,10 +75,11 @@ SWSceneDrawer::SWSceneDrawer()
auto texid = TexMan.CheckForTexture("@@palette@@", ETextureType::Any); auto texid = TexMan.CheckForTexture("@@palette@@", ETextureType::Any);
if (!texid.Exists()) if (!texid.Exists())
{ {
auto tex = new FImageTexture(new FSWPaletteTexture, "@@palette@@"); // 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.
texid = TexMan.AddTexture(tex); auto tex = MakeGameTexture(new FImageTexture(new FSWPaletteTexture, "@@palette@@"));
texid = TexMan.AddGameTexture(tex);
} }
PaletteTexture = TexMan.GetTexture(texid); PaletteTexture = TexMan.GetGameTexture(texid)->GetTexture();
} }
SWSceneDrawer::~SWSceneDrawer() SWSceneDrawer::~SWSceneDrawer()