- removed the conversion helper code and fixed a few places where FMaterial was only used to access the hardware textures in the FTexture class.
This commit is contained in:
parent
7bdef7fe9a
commit
662fa6e667
18 changed files with 68 additions and 56 deletions
|
|
@ -425,8 +425,9 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
|
|||
tex->bWorldPanning = true;
|
||||
tex->bNoDecals = false;
|
||||
tex->SourceLump = -1; // We do not really care.
|
||||
TexMan.AddGameTexture(MakeGameTexture(tex));
|
||||
charMap.Insert(int(position) + x + y * numtex_x, reinterpret_cast<FGameTexture*>(tex));
|
||||
auto gtex = MakeGameTexture(tex);
|
||||
TexMan.AddGameTexture(gtex);
|
||||
charMap.Insert(int(position) + x + y * numtex_x, gtex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -451,7 +452,7 @@ void FFont::ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height
|
|||
auto lump = charMap.CheckKey(FirstChar + i);
|
||||
if (lump != nullptr)
|
||||
{
|
||||
FTexture *pic = (*lump)->GetTexture();
|
||||
auto pic = (*lump)->GetTexture();
|
||||
|
||||
auto b = pic->Get8BitPixels(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@
|
|||
#include "name.h"
|
||||
|
||||
class DCanvas;
|
||||
class FTexture;
|
||||
class FGameTexture;
|
||||
struct FRemapTable;
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
#include "imagehelpers.h"
|
||||
#include "image.h"
|
||||
#include "printf.h"
|
||||
#include "texturemanager.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
@ -608,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 reinterpret_cast<FGameTexture*>(new FPNGFileTexture (png->File, width, height, colortype));
|
||||
else return MakeGameTexture(new FPNGFileTexture (png->File, width, height, colortype));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
|||
|
|
@ -146,21 +146,12 @@ FMaterial::~FMaterial()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
IHardwareTexture *FMaterial::GetLayer(int i, int translation, FTexture **pLayer)
|
||||
IHardwareTexture *FMaterial::GetLayer(int i, int translation, FTexture **pLayer) const
|
||||
{
|
||||
FTexture *layer = i == 0 ? imgtex : mTextureLayers[i - 1];
|
||||
if (pLayer) *pLayer = layer;
|
||||
|
||||
if (layer && layer->UseType!=ETextureType::Null)
|
||||
{
|
||||
IHardwareTexture *hwtex = layer->SystemTextures.GetHardwareTexture(translation, mExpanded);
|
||||
if (hwtex == nullptr)
|
||||
{
|
||||
hwtex = CreateHardwareTexture();
|
||||
layer->SystemTextures.AddHardwareTexture(translation, mExpanded, hwtex);
|
||||
}
|
||||
return hwtex;
|
||||
}
|
||||
if (layer) return layer->GetHardwareTexture(translation, mExpanded);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public:
|
|||
return mTextureLayers.Size() + 1;
|
||||
}
|
||||
|
||||
IHardwareTexture *GetLayer(int i, int translation, FTexture **pLayer = nullptr);
|
||||
IHardwareTexture *GetLayer(int i, int translation, FTexture **pLayer = nullptr) const;
|
||||
|
||||
|
||||
static FMaterial *ValidateTexture(FGameTexture * tex, bool expand, bool create = true);
|
||||
|
|
|
|||
|
|
@ -990,6 +990,27 @@ void FTexture::SetSpriteRect()
|
|||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Create a hardware texture for this texture image.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
IHardwareTexture* FTexture::GetHardwareTexture(int translation, bool expanded)
|
||||
{
|
||||
if (UseType != ETextureType::Null)
|
||||
{
|
||||
IHardwareTexture* hwtex = SystemTextures.GetHardwareTexture(translation, expanded);
|
||||
if (hwtex == nullptr)
|
||||
{
|
||||
hwtex = CreateHardwareTexture();
|
||||
SystemTextures.AddHardwareTexture(translation, expanded, hwtex);
|
||||
}
|
||||
return hwtex;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Coordinate helper.
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ FTextureID FTextureManager::AddGameTexture (FGameTexture *texture)
|
|||
hash = -1;
|
||||
}
|
||||
|
||||
TextureHash hasher = { reinterpret_cast<FGameTexture*>(texture), hash };
|
||||
TextureHash hasher = { texture, hash };
|
||||
int trans = Textures.Push (hasher);
|
||||
Translation.Push (trans);
|
||||
if (bucket >= 0) HashFirst[bucket] = trans;
|
||||
|
|
@ -445,7 +445,7 @@ void FTextureManager::ReplaceTexture (FTextureID picnum, FGameTexture *newtextur
|
|||
|
||||
newtexture->GetTexture()->Name = oldtexture->GetName();
|
||||
newtexture->SetUseType(oldtexture->GetUseType());
|
||||
Textures[index].Texture = reinterpret_cast<FGameTexture*>(newtexture);
|
||||
Textures[index].Texture = newtexture;
|
||||
newtexture->GetTexture()->id = oldtexture->GetID();
|
||||
oldtexture->GetTexture()->Name = "";
|
||||
AddGameTexture(oldtexture);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
class FxAddSub;
|
||||
struct BuildInfo;
|
||||
class FMultipatchTextureBuilder;
|
||||
int PalCheck(int tex);
|
||||
|
||||
// Texture manager
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
typedef TMap<int, bool> SpriteHits;
|
||||
class FImageSource;
|
||||
class FGameTexture;
|
||||
class IHardwareTexture;
|
||||
|
||||
enum MaterialShaderIndex
|
||||
{
|
||||
|
|
@ -257,6 +258,7 @@ public:
|
|||
SpritePositioningInfo spi;
|
||||
int8_t mTrimResult = -1;
|
||||
|
||||
IHardwareTexture* GetHardwareTexture(int translation, bool expanded);
|
||||
static FTexture *CreateTexture(const char *name, int lumpnum, ETextureType usetype);
|
||||
virtual ~FTexture ();
|
||||
virtual FImageSource *GetImage() const { return nullptr; }
|
||||
|
|
@ -757,7 +759,7 @@ public:
|
|||
// Since these properties will later piggyback on existing members of FGameTexture, the accessors need to be here.
|
||||
FGameTexture *GetSkyFace(int num)
|
||||
{
|
||||
return reinterpret_cast<FGameTexture*>(isSkybox() ? static_cast<FSkyBox*>(&wrapped)->faces[num] : nullptr);
|
||||
return (isSkybox() ? static_cast<FSkyBox*>(&wrapped)->faces[num] : nullptr);
|
||||
}
|
||||
bool GetSkyFlip() { return isSkybox() ? static_cast<FSkyBox*>(&wrapped)->fliptop : false; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue