mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-28 23:11:58 +00:00
- reworked the multipatch texture builder to reuse the FImageTexture objects.
This commit is contained in:
parent
59cd049b77
commit
ef8e7a4944
13 changed files with 104 additions and 99 deletions
|
@ -381,7 +381,7 @@ FFont::FFont (const char *name, const char *nametemplate, const char *filetempla
|
||||||
void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height, const DVector2 &Scale)
|
void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height, const DVector2 &Scale)
|
||||||
{
|
{
|
||||||
// all valid lumps must be named with a hex number that represents the Unicode character index for its first character,
|
// all valid lumps must be named with a hex number that represents the Unicode character index for its first character,
|
||||||
TArray<TexPart> part(1, true);
|
TArray<TexPartBuild> part(1, true);
|
||||||
TMap<int, FGameTexture*> charMap;
|
TMap<int, FGameTexture*> charMap;
|
||||||
int minchar = INT_MAX;
|
int minchar = INT_MAX;
|
||||||
int maxchar = INT_MIN;
|
int maxchar = INT_MIN;
|
||||||
|
@ -408,13 +408,10 @@ 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->GetTexture()->GetImage();
|
part[0].TexImage = static_cast<FImageTexture*>(tex->GetTexture());
|
||||||
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);
|
||||||
auto gtex = MakeGameTexture(tex, nullptr, ETextureType::FontChar);
|
auto gtex = MakeGameTexture(tex, nullptr, ETextureType::FontChar);
|
||||||
tex->bMasked = true;
|
|
||||||
tex->bTranslucent = -1;
|
|
||||||
tex->SourceLump = -1; // We do not really care.
|
|
||||||
gtex->SetWorldPanning(true);
|
gtex->SetWorldPanning(true);
|
||||||
gtex->SetOffsets(0, 0, 0);
|
gtex->SetOffsets(0, 0, 0);
|
||||||
gtex->SetOffsets(1, 0, 0);
|
gtex->SetOffsets(1, 0, 0);
|
||||||
|
|
|
@ -46,15 +46,19 @@
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FMultiPatchTexture::FMultiPatchTexture(int w, int h, const TArray<TexPart> &parts, bool complex, bool textual)
|
FMultiPatchTexture::FMultiPatchTexture(int w, int h, const TArray<TexPartBuild> &parts, bool complex, bool textual)
|
||||||
{
|
{
|
||||||
Width = w;
|
Width = w;
|
||||||
Height = h;
|
Height = h;
|
||||||
bComplex = complex;
|
bComplex = complex;
|
||||||
bTextual = textual;
|
bTextual = textual;
|
||||||
Parts = (TexPart*)ImageArena.Alloc(sizeof(TexPart) * parts.Size());
|
Parts = (TexPart*)ImageArena.Alloc(sizeof(TexPart) * parts.Size());
|
||||||
NumParts = parts.Size();
|
NumParts = parts.Size();
|
||||||
memcpy(Parts, parts.Data(), sizeof(TexPart) * parts.Size());
|
memcpy(Parts, parts.Data(), sizeof(TexPart) * parts.Size());
|
||||||
|
for (unsigned i = 0; i < parts.Size(); i++)
|
||||||
|
{
|
||||||
|
Parts[i].Image = parts[i].TexImage->GetImage();
|
||||||
|
}
|
||||||
|
|
||||||
bUseGamePalette = false;
|
bUseGamePalette = false;
|
||||||
if (!bComplex)
|
if (!bComplex)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "textures.h"
|
||||||
|
|
||||||
class FImageTexture;
|
class FImageTexture;
|
||||||
class FTextureManager;
|
class FTextureManager;
|
||||||
|
@ -27,6 +28,18 @@ struct TexPart
|
||||||
uint8_t op = OP_COPY;
|
uint8_t op = OP_COPY;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TexPartBuild
|
||||||
|
{
|
||||||
|
FRemapTable* Translation = nullptr;
|
||||||
|
FImageTexture *TexImage = nullptr;
|
||||||
|
PalEntry Blend = 0;
|
||||||
|
blend_t Alpha = FRACUNIT;
|
||||||
|
int16_t OriginX = 0;
|
||||||
|
int16_t OriginY = 0;
|
||||||
|
uint8_t Rotate = 0;
|
||||||
|
uint8_t op = OP_COPY;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -40,7 +53,7 @@ class FMultiPatchTexture : public FImageSource
|
||||||
friend class FTexture;
|
friend class FTexture;
|
||||||
friend class FGameTexture;
|
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<TexPartBuild> &parts, bool complex, bool textual);
|
||||||
int GetNumParts() const { return NumParts; }
|
int GetNumParts() const { return NumParts; }
|
||||||
// Query some needed info for texture hack support.
|
// Query some needed info for texture hack support.
|
||||||
bool SupportRemap0() override;
|
bool SupportRemap0() override;
|
||||||
|
@ -79,7 +92,7 @@ struct TexInit
|
||||||
{
|
{
|
||||||
FString TexName;
|
FString TexName;
|
||||||
ETextureType UseType = ETextureType::Null;
|
ETextureType UseType = ETextureType::Null;
|
||||||
FTexture *Texture = nullptr;
|
FImageTexture *Texture = nullptr;
|
||||||
bool Silent = false;
|
bool Silent = false;
|
||||||
bool HasLine = false;
|
bool HasLine = false;
|
||||||
bool UseOffsets = false;
|
bool UseOffsets = false;
|
||||||
|
@ -97,7 +110,7 @@ struct FPatchLookup;
|
||||||
struct BuildInfo
|
struct BuildInfo
|
||||||
{
|
{
|
||||||
FString Name;
|
FString Name;
|
||||||
TArray<TexPart> Parts;
|
TArray<TexPartBuild> Parts;
|
||||||
TArray<TexInit> Inits;
|
TArray<TexInit> Inits;
|
||||||
int Width = 0;
|
int Width = 0;
|
||||||
int Height = 0;
|
int Height = 0;
|
||||||
|
@ -109,7 +122,6 @@ struct BuildInfo
|
||||||
bool bNoDecals = false;
|
bool bNoDecals = false;
|
||||||
int LeftOffset[2] = {};
|
int LeftOffset[2] = {};
|
||||||
int TopOffset[2] = {};
|
int TopOffset[2] = {};
|
||||||
FImageTexture* itex = nullptr;
|
|
||||||
FGameTexture *texture = nullptr;
|
FGameTexture *texture = nullptr;
|
||||||
|
|
||||||
void swap(BuildInfo &other)
|
void swap(BuildInfo &other)
|
||||||
|
@ -129,7 +141,6 @@ struct BuildInfo
|
||||||
std::swap(LeftOffset[1], other.LeftOffset[1]);
|
std::swap(LeftOffset[1], other.LeftOffset[1]);
|
||||||
std::swap(TopOffset[0], other.TopOffset[0]);
|
std::swap(TopOffset[0], other.TopOffset[0]);
|
||||||
std::swap(TopOffset[1], other.TopOffset[1]);
|
std::swap(TopOffset[1], other.TopOffset[1]);
|
||||||
std::swap(itex, other.itex);
|
|
||||||
std::swap(texture, other.texture);
|
std::swap(texture, other.texture);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -140,16 +151,17 @@ class FMultipatchTextureBuilder
|
||||||
{
|
{
|
||||||
FTextureManager &TexMan;
|
FTextureManager &TexMan;
|
||||||
TArray<BuildInfo> BuiltTextures;
|
TArray<BuildInfo> BuiltTextures;
|
||||||
TMap<FTexture*, bool> complex;
|
TMap<FGameTexture*, bool> complex;
|
||||||
void(*progressFunc)();
|
void(*progressFunc)();
|
||||||
void(*checkForHacks)(BuildInfo&);
|
void(*checkForHacks)(BuildInfo&);
|
||||||
|
|
||||||
void MakeTexture(BuildInfo &buildinfo, ETextureType usetype);
|
void MakeTexture(BuildInfo &buildinfo, ETextureType usetype);
|
||||||
|
void AddImageToTexture(FImageTexture* tex, BuildInfo& buildinfo);
|
||||||
|
|
||||||
void BuildTexture(const void *texdef, FPatchLookup *patchlookup, int maxpatchnum, bool strife, int deflumpnum, ETextureType usetyoe);
|
void BuildTexture(const void *texdef, FPatchLookup *patchlookup, int maxpatchnum, bool strife, int deflumpnum, ETextureType usetyoe);
|
||||||
void AddTexturesLump(const void *lumpdata, int lumpsize, int deflumpnum, int patcheslump, int firstdup, bool texture1);
|
void AddTexturesLump(const void *lumpdata, int lumpsize, int deflumpnum, int patcheslump, int firstdup, bool texture1);
|
||||||
|
|
||||||
void ParsePatch(FScanner &sc, BuildInfo &info, TexPart &part, TexInit &init);
|
void ParsePatch(FScanner &sc, BuildInfo &info, TexPartBuild &part, TexInit &init);
|
||||||
void ResolvePatches(BuildInfo &buildinfo);
|
void ResolvePatches(BuildInfo &buildinfo);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -623,6 +623,8 @@ FPNGFileTexture::FPNGFileTexture (FileReader &lump, int width, int height, uint8
|
||||||
{
|
{
|
||||||
Width = width;
|
Width = width;
|
||||||
Height = height;
|
Height = height;
|
||||||
|
Masked = false;
|
||||||
|
bTranslucent = false;
|
||||||
fr = std::move(lump);
|
fr = std::move(lump);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ void FImageTexture::SetFromImage()
|
||||||
Width = img->GetWidth();
|
Width = img->GetWidth();
|
||||||
Height = img->GetHeight();
|
Height = img->GetHeight();
|
||||||
|
|
||||||
bMasked = img->bMasked;
|
Masked = img->bMasked;
|
||||||
bTranslucent = img->bTranslucent;
|
bTranslucent = img->bTranslucent;
|
||||||
}
|
}
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Data structures for the TEXTUREx lumps
|
// Data structures for the TEXTUREx lumps
|
||||||
|
@ -85,7 +84,7 @@ struct mappatch_t
|
||||||
struct maptexture_t
|
struct maptexture_t
|
||||||
{
|
{
|
||||||
uint8_t name[8];
|
uint8_t name[8];
|
||||||
uint16_t Flags; // [RH] Was unused
|
uint16_t Flags; // [RH] Was unused
|
||||||
uint8_t ScaleX; // [RH] Scaling (8 is normal)
|
uint8_t ScaleX; // [RH] Scaling (8 is normal)
|
||||||
uint8_t ScaleY; // [RH] Same as above
|
uint8_t ScaleY; // [RH] Same as above
|
||||||
int16_t width;
|
int16_t width;
|
||||||
|
@ -113,7 +112,7 @@ struct strifemappatch_t
|
||||||
struct strifemaptexture_t
|
struct strifemaptexture_t
|
||||||
{
|
{
|
||||||
uint8_t name[8];
|
uint8_t name[8];
|
||||||
uint16_t Flags; // [RH] Was unused
|
uint16_t Flags; // [RH] Was unused
|
||||||
uint8_t ScaleX; // [RH] Scaling (8 is normal)
|
uint8_t ScaleX; // [RH] Scaling (8 is normal)
|
||||||
uint8_t ScaleY; // [RH] Same as above
|
uint8_t ScaleY; // [RH] Same as above
|
||||||
int16_t width;
|
int16_t width;
|
||||||
|
@ -137,22 +136,23 @@ struct FPatchLookup
|
||||||
|
|
||||||
void FMultipatchTextureBuilder::MakeTexture(BuildInfo &buildinfo, ETextureType usetype)
|
void FMultipatchTextureBuilder::MakeTexture(BuildInfo &buildinfo, ETextureType usetype)
|
||||||
{
|
{
|
||||||
FImageTexture *tex = new FImageTexture(nullptr);
|
buildinfo.texture = new FGameTexture(nullptr, buildinfo.Name);
|
||||||
tex->SetSize(buildinfo.Width, buildinfo.Height);
|
buildinfo.texture->SetUseType(usetype);
|
||||||
tex->bMasked = true; // we do not really know yet.
|
TexMan.AddGameTexture(buildinfo.texture);
|
||||||
tex->bTranslucent = -1;
|
}
|
||||||
tex->SourceLump = buildinfo.DefinitionLump;
|
|
||||||
buildinfo.itex = tex;
|
void FMultipatchTextureBuilder::AddImageToTexture(FImageTexture *tex, BuildInfo& buildinfo)
|
||||||
buildinfo.texture = MakeGameTexture(tex, buildinfo.Name, usetype);
|
{
|
||||||
|
buildinfo.texture->Setup(tex);
|
||||||
buildinfo.texture->SetOffsets(0, buildinfo.LeftOffset[0], buildinfo.TopOffset[0]);
|
buildinfo.texture->SetOffsets(0, buildinfo.LeftOffset[0], buildinfo.TopOffset[0]);
|
||||||
buildinfo.texture->SetOffsets(1, buildinfo.LeftOffset[1], buildinfo.TopOffset[1]);
|
buildinfo.texture->SetOffsets(1, buildinfo.LeftOffset[1], buildinfo.TopOffset[1]);
|
||||||
buildinfo.texture->SetScale((float)buildinfo.Scale.X, (float)buildinfo.Scale.X);
|
buildinfo.texture->SetScale((float)buildinfo.Scale.X, (float)buildinfo.Scale.X);
|
||||||
buildinfo.texture->SetWorldPanning(buildinfo.bWorldPanning);
|
buildinfo.texture->SetWorldPanning(buildinfo.bWorldPanning);
|
||||||
buildinfo.texture->SetNoDecals(buildinfo.bNoDecals);
|
buildinfo.texture->SetNoDecals(buildinfo.bNoDecals);
|
||||||
|
calcShouldUpscale(buildinfo.texture); // calculate this once at insertion
|
||||||
TexMan.AddGameTexture(buildinfo.texture);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// The reader for TEXTUREx
|
// The reader for TEXTUREx
|
||||||
|
@ -235,7 +235,7 @@ void FMultipatchTextureBuilder::BuildTexture(const void *texdef, FPatchLookup *p
|
||||||
}
|
}
|
||||||
buildinfo.Parts[i].OriginX = LittleShort(mpatch.d->originx);
|
buildinfo.Parts[i].OriginX = LittleShort(mpatch.d->originx);
|
||||||
buildinfo.Parts[i].OriginY = LittleShort(mpatch.d->originy);
|
buildinfo.Parts[i].OriginY = LittleShort(mpatch.d->originy);
|
||||||
buildinfo.Parts[i].Image = nullptr;
|
buildinfo.Parts[i].TexImage = nullptr;
|
||||||
buildinfo.Inits[i].TexName = patchlookup[LittleShort(mpatch.d->patch)].Name;
|
buildinfo.Inits[i].TexName = patchlookup[LittleShort(mpatch.d->patch)].Name;
|
||||||
buildinfo.Inits[i].UseType = ETextureType::WallPatch;
|
buildinfo.Inits[i].UseType = ETextureType::WallPatch;
|
||||||
if (strife)
|
if (strife)
|
||||||
|
@ -417,7 +417,7 @@ void FMultipatchTextureBuilder::AddTexturesLumps(int lump1, int lump2, int patch
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void FMultipatchTextureBuilder::ParsePatch(FScanner &sc, BuildInfo &info, TexPart & part, TexInit &init)
|
void FMultipatchTextureBuilder::ParsePatch(FScanner &sc, BuildInfo &info, TexPartBuild & part, TexInit &init)
|
||||||
{
|
{
|
||||||
FString patchname;
|
FString patchname;
|
||||||
int Mirror = 0;
|
int Mirror = 0;
|
||||||
|
@ -669,7 +669,7 @@ void FMultipatchTextureBuilder::ParseTexture(FScanner &sc, ETextureType UseType)
|
||||||
}
|
}
|
||||||
else if (sc.Compare("Patch"))
|
else if (sc.Compare("Patch"))
|
||||||
{
|
{
|
||||||
TexPart part;
|
TexPartBuild part;
|
||||||
TexInit init;
|
TexInit init;
|
||||||
ParsePatch(sc, buildinfo, part, init);
|
ParsePatch(sc, buildinfo, part, init);
|
||||||
if (init.TexName.IsNotEmpty())
|
if (init.TexName.IsNotEmpty())
|
||||||
|
@ -681,12 +681,12 @@ void FMultipatchTextureBuilder::ParseTexture(FScanner &sc, ETextureType UseType)
|
||||||
init.sc = sc;
|
init.sc = sc;
|
||||||
buildinfo.Inits.Push(init);
|
buildinfo.Inits.Push(init);
|
||||||
}
|
}
|
||||||
part.Image = nullptr;
|
part.TexImage = nullptr;
|
||||||
part.Translation = nullptr;
|
part.Translation = nullptr;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("Sprite"))
|
else if (sc.Compare("Sprite"))
|
||||||
{
|
{
|
||||||
TexPart part;
|
TexPartBuild part;
|
||||||
TexInit init;
|
TexInit init;
|
||||||
ParsePatch(sc, buildinfo, part, init);
|
ParsePatch(sc, buildinfo, part, init);
|
||||||
if (init.TexName.IsNotEmpty())
|
if (init.TexName.IsNotEmpty())
|
||||||
|
@ -698,12 +698,12 @@ void FMultipatchTextureBuilder::ParseTexture(FScanner &sc, ETextureType UseType)
|
||||||
init.sc = sc;
|
init.sc = sc;
|
||||||
buildinfo.Inits.Push(init);
|
buildinfo.Inits.Push(init);
|
||||||
}
|
}
|
||||||
part.Image = nullptr;
|
part.TexImage = nullptr;
|
||||||
part.Translation = nullptr;
|
part.Translation = nullptr;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("Graphic"))
|
else if (sc.Compare("Graphic"))
|
||||||
{
|
{
|
||||||
TexPart part;
|
TexPartBuild part;
|
||||||
TexInit init;
|
TexInit init;
|
||||||
ParsePatch(sc, buildinfo, part, init);
|
ParsePatch(sc, buildinfo, part, init);
|
||||||
if (init.TexName.IsNotEmpty())
|
if (init.TexName.IsNotEmpty())
|
||||||
|
@ -715,7 +715,7 @@ void FMultipatchTextureBuilder::ParseTexture(FScanner &sc, ETextureType UseType)
|
||||||
init.sc = sc;
|
init.sc = sc;
|
||||||
buildinfo.Inits.Push(init);
|
buildinfo.Inits.Push(init);
|
||||||
}
|
}
|
||||||
part.Image = nullptr;
|
part.TexImage = nullptr;
|
||||||
part.Translation = nullptr;
|
part.Translation = nullptr;
|
||||||
}
|
}
|
||||||
else if (sc.Compare("Offset"))
|
else if (sc.Compare("Offset"))
|
||||||
|
@ -812,12 +812,12 @@ void FMultipatchTextureBuilder::ResolvePatches(BuildInfo &buildinfo)
|
||||||
{
|
{
|
||||||
FGameTexture *tex = TexMan.GetGameTexture(texno);
|
FGameTexture *tex = TexMan.GetGameTexture(texno);
|
||||||
|
|
||||||
if (tex != nullptr && tex->isValid())
|
if (tex != nullptr && tex->isValid() && dynamic_cast<FImageTexture*>(tex->GetTexture()))
|
||||||
{
|
{
|
||||||
//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->GetTexture();
|
buildinfo.Inits[i].Texture = static_cast<FImageTexture*>(tex->GetTexture());
|
||||||
bool iscomplex = !!complex.CheckKey(tex->GetTexture());
|
bool iscomplex = !!complex.CheckKey(tex);
|
||||||
if (iscomplex) complex.Insert(buildinfo.itex, true);
|
if (iscomplex) complex.Insert(buildinfo.texture, true);
|
||||||
buildinfo.bComplex |= iscomplex;
|
buildinfo.bComplex |= iscomplex;
|
||||||
if (buildinfo.Inits[i].UseOffsets)
|
if (buildinfo.Inits[i].UseOffsets)
|
||||||
{
|
{
|
||||||
|
@ -876,12 +876,12 @@ void FMultipatchTextureBuilder::ResolveAllPatches()
|
||||||
|
|
||||||
for (unsigned j = 0; j < buildinfo.Inits.Size(); j++)
|
for (unsigned j = 0; j < buildinfo.Inits.Size(); j++)
|
||||||
{
|
{
|
||||||
if (buildinfo.Parts[j].Image == nullptr)
|
if (buildinfo.Parts[j].TexImage == nullptr)
|
||||||
{
|
{
|
||||||
auto image = buildinfo.Inits[j].Texture->GetImage();
|
auto image = buildinfo.Inits[j].Texture;
|
||||||
if (image != nullptr)
|
if (image->GetImage() != nullptr)
|
||||||
{
|
{
|
||||||
buildinfo.Parts[j].Image = image;
|
buildinfo.Parts[j].TexImage = image;
|
||||||
donesomething = true;
|
donesomething = true;
|
||||||
}
|
}
|
||||||
else hasEmpty = true;
|
else hasEmpty = true;
|
||||||
|
@ -896,19 +896,21 @@ void FMultipatchTextureBuilder::ResolveAllPatches()
|
||||||
if (buildinfo.Parts.Size() == 1)
|
if (buildinfo.Parts.Size() == 1)
|
||||||
{
|
{
|
||||||
if (buildinfo.Parts[0].OriginX == 0 && buildinfo.Parts[0].OriginY == 0 &&
|
if (buildinfo.Parts[0].OriginX == 0 && buildinfo.Parts[0].OriginY == 0 &&
|
||||||
buildinfo.Parts[0].Image->GetWidth() == buildinfo.Width &&
|
buildinfo.Parts[0].TexImage->GetWidth() == buildinfo.Width &&
|
||||||
buildinfo.Parts[0].Image->GetHeight() == buildinfo.Height &&
|
buildinfo.Parts[0].TexImage->GetHeight() == buildinfo.Height &&
|
||||||
buildinfo.Parts[0].Rotate == 0 &&
|
buildinfo.Parts[0].Rotate == 0 &&
|
||||||
!buildinfo.bComplex)
|
!buildinfo.bComplex)
|
||||||
{
|
{
|
||||||
buildinfo.itex->SetImage(buildinfo.Parts[0].Image);
|
AddImageToTexture(buildinfo.Parts[0].TexImage, buildinfo);
|
||||||
|
buildinfo.texture->Setup(buildinfo.Parts[0].TexImage);
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!done)
|
if (!done)
|
||||||
{
|
{
|
||||||
auto img = new FMultiPatchTexture(buildinfo.Width, buildinfo.Height, buildinfo.Parts, buildinfo.bComplex, buildinfo.textual);
|
auto img = new FMultiPatchTexture(buildinfo.Width, buildinfo.Height, buildinfo.Parts, buildinfo.bComplex, buildinfo.textual);
|
||||||
buildinfo.itex->SetImage(img);
|
auto itex = new FImageTexture(img);
|
||||||
|
AddImageToTexture(itex, buildinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
BuiltTextures.Delete(i);
|
BuiltTextures.Delete(i);
|
||||||
|
|
|
@ -59,6 +59,5 @@ void FSkyBox::SetSize()
|
||||||
if (previous && previous->GetTexture()->GetImage())
|
if (previous && previous->GetTexture()->GetImage())
|
||||||
{
|
{
|
||||||
SetImage(previous->GetTexture()->GetImage());
|
SetImage(previous->GetTexture()->GetImage());
|
||||||
SetFromImage();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,12 +89,8 @@ FTexture * FTexture::CreateTexture(int lumpnum, bool allowflats)
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture::FTexture (int lumpnum)
|
FTexture::FTexture (int lumpnum)
|
||||||
:
|
: SourceLump(lumpnum), bHasCanvas(false)
|
||||||
SourceLump(lumpnum),
|
|
||||||
bNoRemap0(false), bMasked(true), bAlphaTexture(false), bHasCanvas(false),
|
|
||||||
Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0)
|
|
||||||
{
|
{
|
||||||
bNoCompress = false;
|
|
||||||
bTranslucent = -1;
|
bTranslucent = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +184,6 @@ void FGameTexture::AddAutoMaterials()
|
||||||
auto bmtex = TexMan.FindGameTexture(fileSystem.GetFileFullName(lump), ETextureType::Any, FTextureManager::TEXMAN_TryAny);
|
auto bmtex = TexMan.FindGameTexture(fileSystem.GetFileFullName(lump), ETextureType::Any, FTextureManager::TEXMAN_TryAny);
|
||||||
if (bmtex != nullptr)
|
if (bmtex != nullptr)
|
||||||
{
|
{
|
||||||
bmtex->GetTexture()->bMasked = false;
|
|
||||||
this->*(layer.pointer) = bmtex->GetTexture();
|
this->*(layer.pointer) = bmtex->GetTexture();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -471,10 +466,10 @@ bool FTexture::SmoothEdges(unsigned char * buffer, int w, int h)
|
||||||
|
|
||||||
bool FTexture::ProcessData(unsigned char * buffer, int w, int h, bool ispatch)
|
bool FTexture::ProcessData(unsigned char * buffer, int w, int h, bool ispatch)
|
||||||
{
|
{
|
||||||
if (bMasked)
|
if (Masked)
|
||||||
{
|
{
|
||||||
bMasked = SmoothEdges(buffer, w, h);
|
Masked = SmoothEdges(buffer, w, h);
|
||||||
if (bMasked && !ispatch) FindHoles(buffer, w, h);
|
if (Masked && !ispatch) FindHoles(buffer, w, h);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -557,15 +552,8 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags)
|
||||||
|
|
||||||
bool FTexture::DetermineTranslucency()
|
bool FTexture::DetermineTranslucency()
|
||||||
{
|
{
|
||||||
if (!bHasCanvas)
|
// This will calculate all we need, so just discard the result.
|
||||||
{
|
CreateTexBuffer(0);
|
||||||
// This will calculate all we need, so just discard the result.
|
|
||||||
CreateTexBuffer(0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bTranslucent = 0;
|
|
||||||
}
|
|
||||||
return !!bTranslucent;
|
return !!bTranslucent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,15 +918,21 @@ FWrapperTexture::FWrapperTexture(int w, int h, int bits)
|
||||||
Width = w;
|
Width = w;
|
||||||
Height = h;
|
Height = h;
|
||||||
Format = bits;
|
Format = bits;
|
||||||
bNoCompress = true;
|
//bNoCompress = true;
|
||||||
auto hwtex = CreateHardwareTexture();
|
auto hwtex = CreateHardwareTexture();
|
||||||
// todo: Initialize here.
|
// todo: Initialize here.
|
||||||
SystemTextures.AddHardwareTexture(0, false, hwtex);
|
SystemTextures.AddHardwareTexture(0, false, hwtex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FGameTexture::FGameTexture(FTexture* wrap, const char *name) : Base(wrap), Name(name)
|
FGameTexture::FGameTexture(FTexture* wrap, const char* name) : Name(name)
|
||||||
{
|
{
|
||||||
|
if (wrap) Setup(wrap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FGameTexture::Setup(FTexture *wrap)
|
||||||
|
{
|
||||||
|
Base = wrap;
|
||||||
id.SetInvalid();
|
id.SetInvalid();
|
||||||
TexelWidth = Base->GetWidth();
|
TexelWidth = Base->GetWidth();
|
||||||
DisplayWidth = (float)TexelWidth;
|
DisplayWidth = (float)TexelWidth;
|
||||||
|
|
|
@ -383,8 +383,11 @@ FTextureID FTextureManager::AddGameTexture (FGameTexture *texture, bool addtohas
|
||||||
|
|
||||||
if (texture == NULL) return FTextureID(-1);
|
if (texture == NULL) return FTextureID(-1);
|
||||||
|
|
||||||
// Later textures take precedence over earlier ones
|
if (texture->GetTexture())
|
||||||
calcShouldUpscale(texture); // calculate this once at insertion
|
{
|
||||||
|
// Later textures take precedence over earlier ones
|
||||||
|
calcShouldUpscale(texture); // calculate this once at insertion
|
||||||
|
}
|
||||||
|
|
||||||
// Textures without name can't be looked for
|
// Textures without name can't be looked for
|
||||||
if (addtohash && texture->GetName().IsNotEmpty())
|
if (addtohash && texture->GetName().IsNotEmpty())
|
||||||
|
@ -1268,9 +1271,10 @@ 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.
|
// 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!
|
// But do not link the new texture into the hash chain!
|
||||||
auto FrontSkyLayer = MakeGameTexture(new FImageTexture(image), tex->GetName(), ETextureType::Wall);
|
auto itex = new FImageTexture(image);
|
||||||
|
itex->SetNoRemap0();
|
||||||
|
auto FrontSkyLayer = MakeGameTexture(itex, tex->GetName(), ETextureType::Wall);
|
||||||
FrontSkyLayer->SetUseType(tex->GetUseType());
|
FrontSkyLayer->SetUseType(tex->GetUseType());
|
||||||
FrontSkyLayer->GetTexture()->bNoRemap0 = true;
|
|
||||||
texid = TexMan.AddGameTexture(FrontSkyLayer, false);
|
texid = TexMan.AddGameTexture(FrontSkyLayer, false);
|
||||||
Textures[texidx].FrontSkyLayer = texid.GetIndex();
|
Textures[texidx].FrontSkyLayer = texid.GetIndex();
|
||||||
Textures[texid.GetIndex()].FrontSkyLayer = texid.GetIndex(); // also let it refer to itself as its front sky layer, in case for repeated InitSkyMap calls.
|
Textures[texid.GetIndex()].FrontSkyLayer = texid.GetIndex(); // also let it refer to itself as its front sky layer, in case for repeated InitSkyMap calls.
|
||||||
|
|
|
@ -240,28 +240,18 @@ struct SpritePositioningInfo
|
||||||
class FTexture : public RefCountedBase
|
class FTexture : public RefCountedBase
|
||||||
{
|
{
|
||||||
friend class FGameTexture; // only for the porting work
|
friend class FGameTexture; // only for the porting work
|
||||||
friend class FTexture;
|
|
||||||
friend struct FTexCoordInfo;
|
|
||||||
friend class FMultipatchTextureBuilder;
|
|
||||||
friend class FMaterial;
|
|
||||||
friend class FFont;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint16_t Width, Height;
|
|
||||||
int SourceLump;
|
|
||||||
FHardwareTextureContainer SystemTextures;
|
FHardwareTextureContainer SystemTextures;
|
||||||
|
|
||||||
uint8_t bNoRemap0 : 1; // Do not remap color 0 (used by front layer of parallax skies)
|
|
||||||
uint8_t bNoCompress : 1;
|
|
||||||
|
|
||||||
uint8_t bMasked : 1; // Texture (might) have holes
|
|
||||||
uint8_t bAlphaTexture : 1; // Texture is an alpha channel without color information
|
|
||||||
uint8_t bHasCanvas : 1; // Texture is based off FCanvasTexture
|
|
||||||
|
|
||||||
int8_t bTranslucent : 2;
|
|
||||||
|
|
||||||
FloatRect* areas = nullptr;
|
FloatRect* areas = nullptr;
|
||||||
int areacount = 0;
|
int SourceLump;
|
||||||
|
uint16_t Width = 0, Height = 0;
|
||||||
|
|
||||||
|
bool Masked = false; // Texture (might) have holes
|
||||||
|
bool bHasCanvas = false;
|
||||||
|
int8_t bTranslucent = -1;
|
||||||
|
int8_t areacount = 0; // this is capped at 4 sections.
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -277,7 +267,6 @@ public:
|
||||||
bool isHardwareCanvas() const { return bHasCanvas; } // There's two here so that this can deal with software canvases in the hardware renderer later.
|
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 isCanvas() const { return bHasCanvas; }
|
||||||
|
|
||||||
bool isMasked() const { return bMasked; }
|
|
||||||
int GetSourceLump() { return SourceLump; } // needed by the scripted GetName method.
|
int GetSourceLump() { return SourceLump; } // needed by the scripted GetName method.
|
||||||
bool FindHoles(const unsigned char * buffer, int w, int h);
|
bool FindHoles(const unsigned char * buffer, int w, int h);
|
||||||
|
|
||||||
|
@ -338,9 +327,7 @@ public:
|
||||||
Width = width;
|
Width = width;
|
||||||
Height = height;
|
Height = height;
|
||||||
|
|
||||||
bMasked = false;
|
|
||||||
bHasCanvas = true;
|
bHasCanvas = true;
|
||||||
bTranslucent = false;
|
|
||||||
aspectRatio = (float)width / height;
|
aspectRatio = (float)width / height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,6 +367,7 @@ public:
|
||||||
class FImageTexture : public FTexture
|
class FImageTexture : public FTexture
|
||||||
{
|
{
|
||||||
FImageSource* mImage;
|
FImageSource* mImage;
|
||||||
|
bool bNoRemap0;
|
||||||
protected:
|
protected:
|
||||||
void SetFromImage();
|
void SetFromImage();
|
||||||
public:
|
public:
|
||||||
|
@ -389,7 +377,9 @@ public:
|
||||||
void SetImage(FImageSource* img) // This is only for the multipatch texture builder!
|
void SetImage(FImageSource* img) // This is only for the multipatch texture builder!
|
||||||
{
|
{
|
||||||
mImage = img;
|
mImage = img;
|
||||||
|
SetFromImage();
|
||||||
}
|
}
|
||||||
|
void SetNoRemap0() { bNoRemap0 = true; }
|
||||||
|
|
||||||
FImageSource* GetImage() const override { return mImage; }
|
FImageSource* GetImage() const override { return mImage; }
|
||||||
FBitmap GetBgraBitmap(const PalEntry* p, int* trans) override;
|
FBitmap GetBgraBitmap(const PalEntry* p, int* trans) override;
|
||||||
|
@ -494,13 +484,14 @@ class FGameTexture
|
||||||
uint16_t GlowHeight;
|
uint16_t GlowHeight;
|
||||||
PalEntry GlowColor = 0;
|
PalEntry GlowColor = 0;
|
||||||
|
|
||||||
int16_t SkyOffset;
|
int16_t SkyOffset = 0;
|
||||||
uint16_t Rotations;
|
uint16_t Rotations = 0xffff;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FGameTexture(FTexture* wrap, const char *name);
|
FGameTexture(FTexture* wrap, const char *name);
|
||||||
~FGameTexture();
|
~FGameTexture();
|
||||||
|
void Setup(FTexture* wrap);
|
||||||
FTextureID GetID() const { return id; }
|
FTextureID GetID() const { return id; }
|
||||||
void SetID(FTextureID newid) { id = newid; } // should only be called by the texture manager
|
void SetID(FTextureID newid) { id = newid; } // should only be called by the texture manager
|
||||||
const FString& GetName() const { return Name; }
|
const FString& GetName() const { return Name; }
|
||||||
|
@ -545,7 +536,7 @@ public:
|
||||||
bool isValid() const { return UseType != ETextureType::Null; }
|
bool isValid() const { return UseType != ETextureType::Null; }
|
||||||
int isWarped() { return warped; }
|
int isWarped() { return warped; }
|
||||||
void SetWarpStyle(int style) { warped = style; }
|
void SetWarpStyle(int style) { warped = style; }
|
||||||
bool isMasked() { return Base->isMasked(); }
|
bool isMasked() { return Base->Masked; }
|
||||||
bool isHardwareCanvas() const { return Base->isHardwareCanvas(); } // There's two here so that this can deal with software canvases in the hardware renderer later.
|
bool isHardwareCanvas() const { return Base->isHardwareCanvas(); } // There's two here so that this can deal with software canvases in the hardware renderer later.
|
||||||
bool isSoftwareCanvas() const { return Base->isCanvas(); }
|
bool isSoftwareCanvas() const { return Base->isCanvas(); }
|
||||||
|
|
||||||
|
|
|
@ -2674,7 +2674,7 @@ static void CheckForHacks(BuildInfo& buildinfo)
|
||||||
buildinfo.Parts.Size() == 1)
|
buildinfo.Parts.Size() == 1)
|
||||||
{
|
{
|
||||||
// This must alter the size of both the texture image and the game texture.
|
// This must alter the size of both the texture image and the game texture.
|
||||||
buildinfo.Height = buildinfo.Parts[0].Image->GetHeight();
|
buildinfo.Height = buildinfo.Parts[0].TexImage->GetHeight();
|
||||||
buildinfo.texture->GetTexture()->SetSize(buildinfo.texture->GetTexelWidth(), buildinfo.Height);
|
buildinfo.texture->GetTexture()->SetSize(buildinfo.texture->GetTexelWidth(), buildinfo.Height);
|
||||||
buildinfo.texture->SetSize(buildinfo.texture->GetTexelWidth(), buildinfo.Height);
|
buildinfo.texture->SetSize(buildinfo.texture->GetTexelWidth(), buildinfo.Height);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -276,7 +276,7 @@ FSoftwareTextureSpan **FSoftwareTexture::CreateSpans (const T *pixels)
|
||||||
{
|
{
|
||||||
FSoftwareTextureSpan **spans, *span;
|
FSoftwareTextureSpan **spans, *span;
|
||||||
|
|
||||||
if (!mSource->isMasked())
|
if (!mTexture->isMasked())
|
||||||
{ // Texture does not have holes, so it can use a simpler span structure
|
{ // Texture does not have holes, so it can use a simpler span structure
|
||||||
spans = (FSoftwareTextureSpan **)M_Malloc (sizeof(FSoftwareTextureSpan*)*GetPhysicalWidth() + sizeof(FSoftwareTextureSpan)*2);
|
spans = (FSoftwareTextureSpan **)M_Malloc (sizeof(FSoftwareTextureSpan*)*GetPhysicalWidth() + sizeof(FSoftwareTextureSpan)*2);
|
||||||
span = (FSoftwareTextureSpan *)&spans[GetPhysicalWidth()];
|
span = (FSoftwareTextureSpan *)&spans[GetPhysicalWidth()];
|
||||||
|
|
|
@ -53,7 +53,7 @@ public:
|
||||||
|
|
||||||
bool isMasked()
|
bool isMasked()
|
||||||
{
|
{
|
||||||
return mSource->isMasked();
|
return mTexture->isMasked();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t GetRotations() const
|
uint16_t GetRotations() const
|
||||||
|
|
Loading…
Reference in a new issue