mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- moved the front layer hack for Hexen's skies to the texture manager.
This commit is contained in:
parent
da873ca8d1
commit
5352682697
10 changed files with 48 additions and 48 deletions
|
@ -217,32 +217,6 @@ FGameTexture *FGameTexture::GetRawTexture()
|
|||
return tex->OffsetLess;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Same shit for a different hack, this time Hexen's front sky layers.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FGameTexture* FGameTexture::GetFrontSkyLayer()
|
||||
{
|
||||
auto tex = GetTexture();
|
||||
if (tex->FrontSkyLayer) return tex->FrontSkyLayer;
|
||||
// Reject anything that cannot have been a front layer for the sky in Hexen.
|
||||
auto image = tex->GetImage();
|
||||
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())
|
||||
{
|
||||
tex->FrontSkyLayer = this;
|
||||
return this;
|
||||
}
|
||||
|
||||
tex->FrontSkyLayer = MakeGameTexture(new FImageTexture(image, ""));
|
||||
TexMan.AddGameTexture(tex->FrontSkyLayer);
|
||||
tex->FrontSkyLayer->GetTexture()->bNoRemap0 = true;
|
||||
return tex->FrontSkyLayer;
|
||||
}
|
||||
|
||||
|
||||
void FTexture::SetDisplaySize(int fitwidth, int fitheight)
|
||||
{
|
||||
Scale.X = double(Width) / fitwidth;
|
||||
|
|
|
@ -375,7 +375,7 @@ bool FTextureManager::OkForLocalization(FTextureID texnum, const char *substitut
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FTextureID FTextureManager::AddGameTexture (FGameTexture *texture)
|
||||
FTextureID FTextureManager::AddGameTexture (FGameTexture *texture, bool addtohash)
|
||||
{
|
||||
int bucket;
|
||||
int hash;
|
||||
|
@ -385,7 +385,7 @@ FTextureID FTextureManager::AddGameTexture (FGameTexture *texture)
|
|||
// Later textures take precedence over earlier ones
|
||||
|
||||
// Textures without name can't be looked for
|
||||
if (texture->GetName().IsNotEmpty())
|
||||
if (addtohash && texture->GetName().IsNotEmpty())
|
||||
{
|
||||
bucket = int(MakeKey (texture->GetName()) % HASH_SIZE);
|
||||
hash = HashFirst[bucket];
|
||||
|
@ -396,7 +396,7 @@ FTextureID FTextureManager::AddGameTexture (FGameTexture *texture)
|
|||
hash = -1;
|
||||
}
|
||||
|
||||
TextureHash hasher = { texture, -1, hash };
|
||||
TextureHash hasher = { texture, -1, -1, hash };
|
||||
int trans = Textures.Push (hasher);
|
||||
Translation.Push (trans);
|
||||
if (bucket >= 0) HashFirst[bucket] = trans;
|
||||
|
@ -1176,6 +1176,38 @@ void FTextureManager::InitPalettedVersions()
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Same shit for a different hack, this time Hexen's front sky layers.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FTextureID FTextureManager::GetFrontSkyLayer(FTextureID texid)
|
||||
{
|
||||
int texidx = texid.GetIndex();
|
||||
if (texidx >= Textures.Size()) return texid;
|
||||
if (Textures[texidx].FrontSkyLayer != -1) return FSetTextureID(Textures[texidx].FrontSkyLayer);
|
||||
|
||||
// Reject anything that cannot have been a front layer for the sky in original Hexen, i.e. it needs to be an unscaled wall texture only using Doom patches.
|
||||
auto tex = Textures[texidx].Texture;
|
||||
auto image = tex->GetTexture()->GetImage();
|
||||
if (image == nullptr || !image->SupportRemap0() || tex->GetUseType() != ETextureType::Wall || tex->useWorldPanning() || tex->GetTexelTopOffset() != 0 ||
|
||||
tex->GetTexelWidth() != tex->GetDisplayWidth() || tex->GetTexelHeight() != tex->GetDisplayHeight())
|
||||
{
|
||||
Textures[texidx].FrontSkyLayer = texidx;
|
||||
return texid;
|
||||
}
|
||||
|
||||
// Set this up so that it serializes to the same info as the base texture - this is needed to restore it on load.
|
||||
auto FrontSkyLayer = MakeGameTexture(new FImageTexture(image, tex->GetName()));
|
||||
FrontSkyLayer->SetUseType(tex->GetUseType());
|
||||
FrontSkyLayer->GetTexture()->bNoRemap0 = true;
|
||||
texid = TexMan.AddGameTexture(FrontSkyLayer);
|
||||
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.
|
||||
return texid;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
bool OkForLocalization(FTextureID texnum, const char *substitute, int locnum);
|
||||
|
||||
void FlushAll();
|
||||
FTextureID GetFrontSkyLayer(FTextureID);
|
||||
|
||||
|
||||
enum
|
||||
|
@ -113,7 +114,7 @@ public:
|
|||
void AddLocalizedVariants();
|
||||
|
||||
FTextureID CreateTexture (int lumpnum, ETextureType usetype=ETextureType::Any); // Also calls AddTexture
|
||||
FTextureID AddGameTexture(FGameTexture* texture);
|
||||
FTextureID AddGameTexture(FGameTexture* texture, bool addtohash = true);
|
||||
FTextureID GetDefaultTexture() const { return DefaultTexture; }
|
||||
|
||||
void LoadTextureX(int wadnum, FMultipatchTextureBuilder &build);
|
||||
|
@ -171,6 +172,7 @@ private:
|
|||
{
|
||||
FGameTexture* Texture;
|
||||
int Paletted; // redirection to paletted variant
|
||||
int FrontSkyLayer;
|
||||
int HashNext;
|
||||
bool HasLocalization;
|
||||
};
|
||||
|
|
|
@ -719,7 +719,6 @@ public:
|
|||
|
||||
// These substitutions must be done on the material level because their sizes can differ. Substitution must happen before any coordinate calculations take place.
|
||||
FGameTexture* GetRawTexture();
|
||||
FGameTexture* GetFrontSkyLayer();
|
||||
|
||||
// Glowing is a pure material property that should not filter down to the actual texture objects.
|
||||
void GetGlowColor(float* data) { wrapped.GetGlowColor(data); }
|
||||
|
|
|
@ -75,7 +75,6 @@ void HWSkyInfo::init(HWDrawInfo *di, int sky1, PalEntry FadeColor)
|
|||
if (di->Level->flags&LEVEL_DOUBLESKY)
|
||||
{
|
||||
auto tex1 = TexMan.GetGameTexture(di->Level->skytexture1, true);
|
||||
if (tex1) tex1 = tex1->GetFrontSkyLayer();
|
||||
texture[1] = tex1;
|
||||
x_offset[1] = di->Level->hw_sky1pos;
|
||||
doublesky = true;
|
||||
|
|
|
@ -75,6 +75,11 @@ void InitSkyMap(FLevelLocals *Level)
|
|||
{
|
||||
Level->skytexture2 = TexMan.CheckForTexture("-noflat-", ETextureType::Any);
|
||||
}
|
||||
if (Level->flags & LEVEL_DOUBLESKY)
|
||||
{
|
||||
Level->skytexture1 = TexMan.GetFrontSkyLayer(Level->skytexture1);
|
||||
}
|
||||
|
||||
|
||||
skytex1 = TexMan.GetGameTexture(Level->skytexture1, false);
|
||||
skytex2 = TexMan.GetGameTexture(Level->skytexture2, false);
|
||||
|
@ -82,10 +87,6 @@ void InitSkyMap(FLevelLocals *Level)
|
|||
if (skytex1 == nullptr)
|
||||
return;
|
||||
|
||||
if (Level->flags & LEVEL_DOUBLESKY)
|
||||
{
|
||||
skytex1 = skytex1->GetFrontSkyLayer();
|
||||
}
|
||||
|
||||
if ((Level->flags & LEVEL_DOUBLESKY) && skytex1->GetDisplayHeight() != skytex2->GetDisplayHeight())
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ namespace swrenderer
|
|||
auto viewport = Thread->Viewport.get();
|
||||
Clip3DFloors *clip3d = Thread->Clip3D.get();
|
||||
|
||||
auto tex = GetPalettedSWTexture(curline->sidedef->GetTexture(side_t::mid), true, curline->GetLevel());
|
||||
auto tex = GetPalettedSWTexture(curline->sidedef->GetTexture(side_t::mid), true, !!(curline->GetLevel()->i_compatflags & COMPATF_MASKEDMIDTEX));
|
||||
const short *mfloorclip = ds->drawsegclip.sprbottomclip;
|
||||
const short *mceilingclip = ds->drawsegclip.sprtopclip;
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace swrenderer
|
|||
Thread = thread;
|
||||
auto Level = Thread->Viewport->Level();
|
||||
|
||||
auto sskytex1 = GetPalettedSWTexture(Level->skytexture1, true, nullptr, true, !!(Level->flags & LEVEL_DOUBLESKY));
|
||||
auto sskytex1 = GetPalettedSWTexture(Level->skytexture1, true, nullptr, true);
|
||||
auto sskytex2 = GetPalettedSWTexture(Level->skytexture2, true, nullptr, true);
|
||||
|
||||
if (sskytex1 == nullptr)
|
||||
|
|
|
@ -612,19 +612,12 @@ CUSTOM_CVAR(Bool, vid_nopalsubstitutions, false, CVAR_ARCHIVE | CVAR_NOINITCALL)
|
|||
R_InitSkyMap();
|
||||
}
|
||||
|
||||
FSoftwareTexture* GetPalettedSWTexture(FTextureID texid, bool animate, FLevelLocals *checkcompat, bool allownull, bool frontsky)
|
||||
FSoftwareTexture* GetPalettedSWTexture(FTextureID texid, bool animate, bool checkcompat, bool allownull)
|
||||
{
|
||||
bool needpal = !vid_nopalsubstitutions && !V_IsTrueColor();
|
||||
auto tex = TexMan.GetPalettedTexture(texid, true, needpal);
|
||||
if (tex == nullptr || (!allownull && !tex->isValid())) return nullptr;
|
||||
if (frontsky)
|
||||
{
|
||||
tex = tex->GetFrontSkyLayer();
|
||||
}
|
||||
else if (checkcompat && checkcompat->i_compatflags & COMPATF_MASKEDMIDTEX)
|
||||
{
|
||||
tex = tex->GetRawTexture();
|
||||
}
|
||||
if (checkcompat) tex = tex->GetRawTexture();
|
||||
return GetSoftwareTexture(tex);
|
||||
}
|
||||
|
||||
|
|
|
@ -193,4 +193,4 @@ public:
|
|||
};
|
||||
|
||||
FSoftwareTexture* GetSoftwareTexture(FGameTexture* tex);
|
||||
FSoftwareTexture* GetPalettedSWTexture(FTextureID texid, bool animate, FLevelLocals *checkcompat = nullptr, bool allownull = false, bool frontsky = false);
|
||||
FSoftwareTexture* GetPalettedSWTexture(FTextureID texid, bool animate, bool checkcompat = false, bool allownull = false);
|
||||
|
|
Loading…
Reference in a new issue