mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- moved the texture ID up one level.
This commit is contained in:
parent
7641da8b7b
commit
d1da26895b
3 changed files with 47 additions and 39 deletions
|
@ -70,36 +70,16 @@ int r_spriteadjustSW, r_spriteadjustHW;
|
|||
|
||||
// Examines the lump contents to decide what type of texture to create,
|
||||
// and creates the texture.
|
||||
FTexture * FTexture::CreateTexture(const char *name, int lumpnum, ETextureType usetype)
|
||||
FTexture * FTexture::CreateTexture(const char *name, int lumpnum, bool allowflats)
|
||||
{
|
||||
if (lumpnum == -1) return nullptr;
|
||||
|
||||
auto image = FImageSource::GetImage(lumpnum, usetype == ETextureType::Flat);
|
||||
auto image = FImageSource::GetImage(lumpnum, allowflats);
|
||||
if (image != nullptr)
|
||||
{
|
||||
FTexture *tex = new FImageTexture(image);
|
||||
if (tex != nullptr)
|
||||
{
|
||||
//tex->UseType = usetype;
|
||||
if (usetype == ETextureType::Flat)
|
||||
{
|
||||
int w = tex->GetTexelWidth();
|
||||
int h = tex->GetTexelHeight();
|
||||
|
||||
// Auto-scale flats with dimensions 128x128 and 256x256.
|
||||
// In hindsight, a bad idea, but RandomLag made it sound better than it really is.
|
||||
// Now we're stuck with this stupid behaviour.
|
||||
if (w==128 && h==128)
|
||||
{
|
||||
tex->Scale.X = tex->Scale.Y = 2;
|
||||
tex->bWorldPanning = true;
|
||||
}
|
||||
else if (w==256 && h==256)
|
||||
{
|
||||
tex->Scale.X = tex->Scale.Y = 4;
|
||||
tex->bWorldPanning = true;
|
||||
}
|
||||
}
|
||||
tex->Name = name;
|
||||
tex->Name.ToUpper();
|
||||
return tex;
|
||||
|
@ -132,7 +112,6 @@ FTexture::FTexture (const char *name, int lumpnum)
|
|||
|
||||
|
||||
_LeftOffset[0] = _LeftOffset[1] = _TopOffset[0] = _TopOffset[1] = 0;
|
||||
id.SetInvalid();
|
||||
if (name != NULL)
|
||||
{
|
||||
Name = name;
|
||||
|
|
|
@ -230,7 +230,7 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset
|
|||
if (tex == NO_TEXTURE) return FTextureID(-1);
|
||||
if (tex != NULL) return tex->GetID();
|
||||
if (flags & TEXMAN_DontCreate) return FTextureID(-1); // we only want to check, there's no need to create a texture if we don't have one yet.
|
||||
tex = MakeGameTexture(FTexture::CreateTexture("", lump, ETextureType::Override), ETextureType::Override);
|
||||
tex = MakeGameTexture(FTexture::CreateTexture("", lump), ETextureType::Override);
|
||||
if (tex != NULL)
|
||||
{
|
||||
tex->AddAutoMaterials();
|
||||
|
@ -402,7 +402,9 @@ FTextureID FTextureManager::AddGameTexture (FGameTexture *texture, bool addtohas
|
|||
int trans = Textures.Push (hasher);
|
||||
Translation.Push (trans);
|
||||
if (bucket >= 0) HashFirst[bucket] = trans;
|
||||
return (texture->GetTexture()->id = FTextureID(trans));
|
||||
auto id = FTextureID(trans);
|
||||
texture->SetID(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -419,9 +421,32 @@ FTextureID FTextureManager::CreateTexture (int lumpnum, ETextureType usetype)
|
|||
{
|
||||
FString str;
|
||||
fileSystem.GetFileShortName(str, lumpnum);
|
||||
auto out = MakeGameTexture(FTexture::CreateTexture(str, lumpnum, usetype), usetype);
|
||||
auto out = MakeGameTexture(FTexture::CreateTexture(str, lumpnum, usetype == ETextureType::Flat), usetype);
|
||||
|
||||
if (out != NULL) return AddGameTexture (out);
|
||||
if (out != NULL)
|
||||
{
|
||||
if (usetype == ETextureType::Flat)
|
||||
{
|
||||
int w = out->GetTexelWidth();
|
||||
int h = out->GetTexelHeight();
|
||||
|
||||
// Auto-scale flats with dimensions 128x128 and 256x256.
|
||||
// In hindsight, a bad idea, but RandomLag made it sound better than it really is.
|
||||
// Now we're stuck with this stupid behaviour.
|
||||
if (w == 128 && h == 128)
|
||||
{
|
||||
out->SetScale(DVector2(2, 2));
|
||||
out->SetWorldPanning(true);
|
||||
}
|
||||
else if (w == 256 && h == 256)
|
||||
{
|
||||
out->SetScale(DVector2(4, 4));
|
||||
out->SetWorldPanning(true);
|
||||
}
|
||||
}
|
||||
|
||||
return AddGameTexture(out);
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf (TEXTCOLOR_ORANGE "Invalid data encountered for texture %s\n", fileSystem.GetFileFullPath(lumpnum).GetChars());
|
||||
|
@ -448,7 +473,7 @@ void FTextureManager::ReplaceTexture (FTextureID picnum, FGameTexture *newtextur
|
|||
newtexture->GetTexture()->Name = oldtexture->GetName();
|
||||
newtexture->SetUseType(oldtexture->GetUseType());
|
||||
Textures[index].Texture = newtexture;
|
||||
newtexture->GetTexture()->id = oldtexture->GetID();
|
||||
newtexture->SetID(oldtexture->GetID());
|
||||
oldtexture->GetTexture()->Name = "";
|
||||
AddGameTexture(oldtexture);
|
||||
}
|
||||
|
@ -559,7 +584,7 @@ void FTextureManager::AddHiresTextures (int wadnum)
|
|||
if (amount == 0)
|
||||
{
|
||||
// A texture with this name does not yet exist
|
||||
auto newtex = MakeGameTexture(FTexture::CreateTexture (Name, firsttx, ETextureType::Any), ETextureType::Override);
|
||||
auto newtex = MakeGameTexture(FTexture::CreateTexture (Name, firsttx), ETextureType::Override);
|
||||
if (newtex != NULL)
|
||||
{
|
||||
AddGameTexture(newtex);
|
||||
|
@ -569,7 +594,7 @@ void FTextureManager::AddHiresTextures (int wadnum)
|
|||
{
|
||||
for(unsigned int i = 0; i < tlist.Size(); i++)
|
||||
{
|
||||
FTexture * newtex = FTexture::CreateTexture ("", firsttx, ETextureType::Any);
|
||||
FTexture * newtex = FTexture::CreateTexture ("", firsttx);
|
||||
if (newtex != NULL)
|
||||
{
|
||||
auto oldtex = Textures[tlist[i].GetIndex()].Texture;
|
||||
|
@ -668,7 +693,7 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build
|
|||
(sl=oldtex->GetSourceLump()) >= 0 && fileSystem.GetFileNamespace(sl) == ns_sprites)
|
||||
)
|
||||
{
|
||||
FTexture * newtex = FTexture::CreateTexture ("", lumpnum, ETextureType::Any);
|
||||
FTexture * newtex = FTexture::CreateTexture ("", lumpnum);
|
||||
if (newtex != NULL)
|
||||
{
|
||||
// Replace the entire texture and adjust the scaling and offset factors.
|
||||
|
@ -707,7 +732,7 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build
|
|||
|
||||
if (lumpnum>=0)
|
||||
{
|
||||
auto newtex = MakeGameTexture(FTexture::CreateTexture(src, lumpnum, ETextureType::Override), ETextureType::Override);
|
||||
auto newtex = MakeGameTexture(FTexture::CreateTexture(src, lumpnum), ETextureType::Override);
|
||||
|
||||
if (newtex != NULL)
|
||||
{
|
||||
|
@ -927,7 +952,7 @@ void FTextureManager::AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &b
|
|||
|
||||
// Try to create a texture from this lump and add it.
|
||||
// Unfortunately we have to look at everything that comes through here...
|
||||
auto out = MakeGameTexture(FTexture::CreateTexture(Name, i, ETextureType::MiscPatch), skin ? ETextureType::SkinGraphic : ETextureType::MiscPatch);
|
||||
auto out = MakeGameTexture(FTexture::CreateTexture(Name, i), skin ? ETextureType::SkinGraphic : ETextureType::MiscPatch);
|
||||
|
||||
if (out != NULL)
|
||||
{
|
||||
|
|
|
@ -249,12 +249,11 @@ class FTexture : public RefCountedBase
|
|||
public:
|
||||
|
||||
IHardwareTexture* GetHardwareTexture(int translation, int scaleflags);
|
||||
static FTexture *CreateTexture(const char *name, int lumpnum, ETextureType UseType);
|
||||
static FTexture *CreateTexture(const char *name, int lumpnum, bool allowflats = false);
|
||||
virtual ~FTexture ();
|
||||
virtual FImageSource *GetImage() const { return nullptr; }
|
||||
void CreateUpsampledTextureBuffer(FTextureBuffer &texbuffer, bool hasAlpha, bool checkonly);
|
||||
void CleanHardwareTextures(bool reallyclean);
|
||||
void SetSpriteRect();
|
||||
|
||||
// These are mainly meant for 2D code which only needs logical information about the texture to position it properly.
|
||||
int GetDisplayWidth() { int foo = int((Width * 2) / Scale.X); return (foo >> 1) + (foo & 1); }
|
||||
|
@ -289,7 +288,6 @@ public:
|
|||
bool isMasked() const { return bMasked; }
|
||||
void SetSkyOffset(int offs) { SkyOffset = offs; }
|
||||
int GetSkyOffset() const { return SkyOffset; }
|
||||
FTextureID GetID() const { return id; }
|
||||
PalEntry GetSkyCapColor(bool bottom);
|
||||
virtual int GetSourceLump() { return SourceLump; } // needed by the scripted GetName method.
|
||||
void GetGlowColor(float *data);
|
||||
|
@ -338,7 +336,6 @@ protected:
|
|||
DVector2 Scale;
|
||||
|
||||
int SourceLump;
|
||||
FTextureID id;
|
||||
|
||||
public:
|
||||
FHardwareTextureContainer SystemTextures;
|
||||
|
@ -604,6 +601,8 @@ class FGameTexture
|
|||
RefCountedPtr<FTexture> AmbientOcclusion; // Ambient occlusion texture for PBR
|
||||
RefCountedPtr<FTexture> CustomShaderTextures[MAX_CUSTOM_HW_SHADER_TEXTURES]; // Custom texture maps for custom hardware shaders
|
||||
|
||||
FTextureID id;
|
||||
|
||||
int8_t shouldUpscaleFlag = 0; // Without explicit setup, scaling is disabled for a texture.
|
||||
ETextureType UseType = ETextureType::Wall; // This texture's primary purpose
|
||||
SpritePositioningInfo* spi = nullptr;
|
||||
|
@ -612,8 +611,14 @@ class FGameTexture
|
|||
FMaterial* Material[4] = { };
|
||||
|
||||
public:
|
||||
FGameTexture(FTexture* wrap) : Base(wrap) {}
|
||||
FGameTexture(FTexture* wrap) : Base(wrap)
|
||||
{
|
||||
id.SetInvalid();
|
||||
}
|
||||
~FGameTexture();
|
||||
FTextureID GetID() const { return id; }
|
||||
void SetID(FTextureID newid) { id = newid; } // should only be called by the texture manager
|
||||
|
||||
void CreateDefaultBrightmap();
|
||||
void AddAutoMaterials();
|
||||
bool ShouldExpandSprite();
|
||||
|
@ -664,7 +669,6 @@ public:
|
|||
void SetRotations(int index) { Base->SetRotations(index); }
|
||||
void SetSkyOffset(int ofs) { Base->SetSkyOffset(ofs); }
|
||||
int GetSkyOffset() const { return Base->GetSkyOffset(); }
|
||||
FTextureID GetID() const { return Base->GetID(); }
|
||||
void SetScale(DVector2 vec) { Base->SetScale(vec); }
|
||||
|
||||
ISoftwareTexture* GetSoftwareTexture()
|
||||
|
|
Loading…
Reference in a new issue