diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index d93a3a5f80..9f28fe0387 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -132,7 +132,7 @@ int FMaterial::mMaxBound; FMaterial::FMaterial(FTexture * tx, bool expanded) { mShaderIndex = SHADER_Default; - tex = tx; + sourcetex = tex = tx; // TODO: apply custom shader object here /* if (tx->CustomShaderDefinition) @@ -211,10 +211,11 @@ FMaterial::FMaterial(FTexture * tx, bool expanded) mSpriteU[0] = mSpriteV[0] = 0.f; mSpriteU[1] = mSpriteV[1] = 1.f; - FTexture *basetex = (tx->bWarped && gl.legacyMode)? tx : tx->GetRedirect(false); + FTexture *basetex = tx->GetRedirect(); // allow the redirect only if the texture is not expanded or the scale matches. if (!expanded || (tx->Scale.X == basetex->Scale.X && tx->Scale.Y == basetex->Scale.Y)) { + sourcetex = basetex; mBaseLayer = ValidateSysTexture(basetex, expanded); } @@ -326,7 +327,7 @@ bool FMaterial::TrimBorders(uint16_t *rect) int w; int h; - unsigned char *buffer = tex->CreateTexBuffer(0, w, h); + unsigned char *buffer = sourcetex->CreateTexBuffer(0, w, h); if (buffer == NULL) { @@ -549,8 +550,8 @@ int FMaterial::GetAreas(FloatRect **pAreas) const { if (mShaderIndex == SHADER_Default) // texture splitting can only be done if there's no attached effects { - *pAreas = tex->areas; - return tex->areacount; + *pAreas = sourcetex->areas; + return sourcetex->areacount; } else { @@ -569,7 +570,7 @@ void FMaterial::BindToFrameBuffer() if (mBaseLayer == nullptr) { // must create the hardware texture first - mBaseLayer->BindOrCreate(tex, 0, 0, 0, 0); + mBaseLayer->BindOrCreate(sourcetex, 0, 0, 0, 0); FHardwareTexture::Unbind(0); ClearLastTexture(); } diff --git a/src/gl/textures/gl_material.h b/src/gl/textures/gl_material.h index 9cb17d8c33..3d4c2cc6af 100644 --- a/src/gl/textures/gl_material.h +++ b/src/gl/textures/gl_material.h @@ -87,6 +87,7 @@ class FMaterial public: FTexture *tex; + FTexture *sourcetex; // in case of redirection this is different from tex. FMaterial(FTexture *tex, bool forceexpand); ~FMaterial(); @@ -101,7 +102,7 @@ public: } bool isMasked() const { - return !!tex->bMasked; + return !!sourcetex->bMasked; } int GetLayers() const diff --git a/src/textures/formats/multipatchtexture.cpp b/src/textures/formats/multipatchtexture.cpp index adbca13aa8..bc8b7cea2c 100644 --- a/src/textures/formats/multipatchtexture.cpp +++ b/src/textures/formats/multipatchtexture.cpp @@ -158,7 +158,7 @@ public: int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL) override; int GetSourceLump() override { return DefinitionLump; } - FTexture *GetRedirect(bool wantwarped) override; + FTexture *GetRedirect() override; FTexture *GetRawTexture() override; void ResolvePatches(); @@ -692,7 +692,7 @@ void FMultiPatchTexture::CheckForHacks () // //========================================================================== -FTexture *FMultiPatchTexture::GetRedirect(bool wantwarped) +FTexture *FMultiPatchTexture::GetRedirect() { return bRedirect ? Parts->Texture : this; } diff --git a/src/textures/formats/warptexture.cpp b/src/textures/formats/warptexture.cpp index 3a5323b3df..88a761ba03 100644 --- a/src/textures/formats/warptexture.cpp +++ b/src/textures/formats/warptexture.cpp @@ -120,24 +120,13 @@ int FWarpTexture::NextPo2 (int v) return ++v; } -//========================================================================== -// -// FMultiPatchTexture :: TexPart :: TexPart -// -//========================================================================== - -FTexture *FWarpTexture::GetRedirect(bool wantwarped) -{ - if (!wantwarped) return SourcePic->GetRedirect(false); - else return this; -} - //========================================================================== // // FMultiPatchTexture :: CopyTrueColorPixels // -// This doesn't warp. It's just here in case someone tries to use a warp -// texture for compositing a multipatch texture +// True color texture generation must never hit the paletted path which +// always warps the buffer. +// As a result even CopyTrueColorTranslated must be overrideen here. // //========================================================================== @@ -146,3 +135,8 @@ int FWarpTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FC return SourcePic->CopyTrueColorPixels(bmp, x, y, rotate, inf); } +int FWarpTexture::CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, PalEntry *remap, FCopyInfo *inf) +{ + return SourcePic->CopyTrueColorTranslated(bmp, x, y, rotate, remap, inf); +} + diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index e21158f838..d45fb14331 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -888,7 +888,7 @@ bool FTexture::UseBasePalette() return true; } -FTexture *FTexture::GetRedirect(bool wantwarped) +FTexture *FTexture::GetRedirect() { return this; } diff --git a/src/textures/textures.h b/src/textures/textures.h index d03ef07bfa..a979aad356 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -302,10 +302,10 @@ public: virtual bool Mipmapped() { return true; } virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL); - int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, PalEntry *remap, FCopyInfo *inf = NULL); + virtual int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, PalEntry *remap, FCopyInfo *inf = NULL); virtual bool UseBasePalette(); virtual int GetSourceLump() { return SourceLump; } - virtual FTexture *GetRedirect(bool wantwarped); + virtual FTexture *GetRedirect(); virtual FTexture *GetRawTexture(); // for FMultiPatchTexture to override virtual void Unload (); @@ -725,13 +725,13 @@ public: void Unload() override; virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL) override; + virtual int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, PalEntry *remap, FCopyInfo *inf = NULL) override; const uint32_t *GetPixelsBgra() override; bool CheckModified (FRenderStyle) override; float GetSpeed() const { return Speed; } int GetSourceLump() { return SourcePic->GetSourceLump(); } void SetSpeed(float fac) { Speed = fac; } - FTexture *GetRedirect(bool wantwarped); uint64_t GenTime[2] = { 0, 0 }; uint64_t GenTimeBgra = 0;