diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6166ea2fe9..7d6b7f4eb3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1119,7 +1119,6 @@ set (PCH_SOURCES textures/formats/emptytexture.cpp textures/formats/shadertexture.cpp textures/formats/tgatexture.cpp - textures/formats/worldtexture.cpp textures/hires/hqresize.cpp textures/hires/hirestex.cpp xlat/parse_xlat.cpp diff --git a/src/r_data/models/models_voxel.cpp b/src/r_data/models/models_voxel.cpp index 5b8e825710..6be9d0355a 100644 --- a/src/r_data/models/models_voxel.cpp +++ b/src/r_data/models/models_voxel.cpp @@ -32,6 +32,7 @@ #include "textures/bitmap.h" #include "g_levellocals.h" #include "models.h" +#include "image.h" #ifdef _MSC_VER #pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data @@ -46,13 +47,12 @@ // //=========================================================================== -class FVoxelTexture : public FWorldTexture +class FVoxelTexture : public FImageSource { public: FVoxelTexture(FVoxel *voxel); int CopyPixels(FBitmap *bmp) override; - bool UseBasePalette() override { return false; } TArray Get8BitPixels(bool alphatex) override; protected: @@ -70,7 +70,7 @@ FVoxelTexture::FVoxelTexture(FVoxel *vox) SourceVox = vox; Width = 16; Height = 16; - bNoCompress = true; + //bNoCompress = true; } //=========================================================================== @@ -156,7 +156,7 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned) { mVoxel = voxel; mOwningVoxel = owned; - mPalette = TexMan.AddTexture(new FVoxelTexture(voxel)); + mPalette = TexMan.AddTexture(new FImageTexture(new FVoxelTexture(voxel))); } //=========================================================================== diff --git a/src/textures/formats/automaptexture.cpp b/src/textures/formats/automaptexture.cpp index 3c37636786..39285d2803 100644 --- a/src/textures/formats/automaptexture.cpp +++ b/src/textures/formats/automaptexture.cpp @@ -40,6 +40,7 @@ #include "w_wad.h" #include "textures/textures.h" #include "imagehelpers.h" +#include "image.h" //========================================================================== // @@ -47,7 +48,7 @@ // //========================================================================== -class FAutomapTexture : public FWorldTexture +class FAutomapTexture : public FImageSource { public: FAutomapTexture(int lumpnum); @@ -65,9 +66,9 @@ public: FTexture *AutomapTexture_TryCreate(FileReader &data, int lumpnum) { - if (data.GetLength() < 320) return NULL; - if (!Wads.CheckLumpName(lumpnum, "AUTOPAGE")) return NULL; - return new FAutomapTexture(lumpnum); + if (data.GetLength() < 320) return nullptr; + if (!Wads.CheckLumpName(lumpnum, "AUTOPAGE")) return nullptr; + return new FImageTexture(new FAutomapTexture(lumpnum)); } //========================================================================== @@ -77,10 +78,11 @@ FTexture *AutomapTexture_TryCreate(FileReader &data, int lumpnum) //========================================================================== FAutomapTexture::FAutomapTexture (int lumpnum) -: FWorldTexture(NULL, lumpnum) +: FImageSource(lumpnum) { Width = 320; Height = uint16_t(Wads.LumpLength(lumpnum) / 320); + bUseGamePalette = true; } //========================================================================== diff --git a/src/textures/formats/brightmaptexture.cpp b/src/textures/formats/brightmaptexture.cpp index 06cc29e902..1277cf5273 100644 --- a/src/textures/formats/brightmaptexture.cpp +++ b/src/textures/formats/brightmaptexture.cpp @@ -39,17 +39,17 @@ #include "r_data/r_translate.h" #include "bitmap.h" #include "v_video.h" +#include "image.h" -class FBrightmapTexture : public FWorldTexture +class FBrightmapTexture : public FImageSource { public: - FBrightmapTexture (FTexture *source); + FBrightmapTexture (FImageSource *source); int CopyPixels(FBitmap *bmp) override; - bool UseBasePalette() override { return false; } protected: - FTexture *SourcePic; + FImageSource *SourcePic; }; //=========================================================================== @@ -60,17 +60,12 @@ protected: // //=========================================================================== -FBrightmapTexture::FBrightmapTexture (FTexture *source) +FBrightmapTexture::FBrightmapTexture (FImageSource *source) { - Name = ""; SourcePic = source; - CopySize(source); - bNoDecals = true; - Rotations = 0xffff; - UseType = ETextureType::Override; + Width = source->GetWidth(); + Height = source->GetHeight(); bMasked = false; - id.SetInvalid(); - SourceLump = -1; } int FBrightmapTexture::CopyPixels(FBitmap *bmp) @@ -79,7 +74,7 @@ int FBrightmapTexture::CopyPixels(FBitmap *bmp) return 0; } -FTexture *CreateBrightmapTexture(FTexture *tex) +FTexture *CreateBrightmapTexture(FImageSource *tex) { - return new FBrightmapTexture(tex); + return new FImageTexture(new FBrightmapTexture(tex)); } \ No newline at end of file diff --git a/src/textures/formats/buildtexture.cpp b/src/textures/formats/buildtexture.cpp index ede4a5a764..8900d54005 100644 --- a/src/textures/formats/buildtexture.cpp +++ b/src/textures/formats/buildtexture.cpp @@ -44,6 +44,7 @@ #include "textures/textures.h" #include "r_data/sprites.h" #include "resourcefiles/resourcefile.h" +#include "image.h" //========================================================================== @@ -52,13 +53,12 @@ // //========================================================================== -class FBuildTexture : public FWorldTexture +class FBuildTexture : public FImageSource { public: FBuildTexture (const FString &pathprefix, int tilenum, const uint8_t *pixels, int translation, int width, int height, int left, int top); TArray Get8BitPixels(bool alphatex) override; int CopyPixels(FBitmap *bmp) override; - bool UseBasePalette() override { return false; } protected: const uint8_t *RawPixels; @@ -77,10 +77,8 @@ FBuildTexture::FBuildTexture(const FString &pathprefix, int tilenum, const uint8 { Width = width; Height = height; - _LeftOffset[1] = _LeftOffset[0] = left; - _TopOffset[1] = _TopOffset[0] = top; - Name.Format("%sBTIL%04d", pathprefix.GetChars(), tilenum); - UseType = ETextureType::Override; + LeftOffset = left; + TopOffset = top; } TArray FBuildTexture::Get8BitPixels(bool alphatex) @@ -136,9 +134,12 @@ void FTextureManager::AddTiles (const FString &pathprefix, const void *tiles, in if (width <= 0 || height <= 0) continue; - tex = new FBuildTexture (pathprefix, i, tiledata, translation, width, height, xoffs, yoffs); + tex = new FImageTexture(new FBuildTexture (pathprefix, i, tiledata, translation, width, height, xoffs, yoffs)); texnum = AddTexture (tex); tiledata += size; + tex->Name.Format("%sBTIL%04d", pathprefix.GetChars(), i); + tex->UseType = ETextureType::Override; + // reactivate only if the texture counter works here. //StartScreen->Progress(); diff --git a/src/textures/formats/ddstexture.cpp b/src/textures/formats/ddstexture.cpp index 4d84c365ad..f00a14172f 100644 --- a/src/textures/formats/ddstexture.cpp +++ b/src/textures/formats/ddstexture.cpp @@ -54,6 +54,7 @@ #include "bitmap.h" #include "v_video.h" #include "imagehelpers.h" +#include "image.h" // Since we want this to compile under Linux too, we need to define this // stuff ourselves instead of including a DirectX header. @@ -152,7 +153,7 @@ struct DDSFileHeader // //========================================================================== -class FDDSTexture : public FWorldTexture +class FDDSTexture : public FImageSource { enum { @@ -273,7 +274,7 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum) { return NULL; } - return new FDDSTexture (data, lumpnum, &surfdesc); + return new FImageTexture(new FDDSTexture (data, lumpnum, &surfdesc)); } //========================================================================== @@ -283,13 +284,11 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum) //========================================================================== FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc) -: FWorldTexture(NULL, lumpnum) +: FImageSource(lumpnum) { DDSURFACEDESC2 *surf = (DDSURFACEDESC2 *)vsurfdesc; - UseType = ETextureType::MiscPatch; bMasked = false; - Width = uint16_t(surf->Width); Height = uint16_t(surf->Height); diff --git a/src/textures/formats/emptytexture.cpp b/src/textures/formats/emptytexture.cpp index d793c9fb32..1246760b3f 100644 --- a/src/textures/formats/emptytexture.cpp +++ b/src/textures/formats/emptytexture.cpp @@ -39,6 +39,7 @@ #include "files.h" #include "w_wad.h" #include "textures/textures.h" +#include "image.h" //========================================================================== // @@ -46,7 +47,7 @@ // //========================================================================== -class FEmptyTexture : public FWorldTexture +class FEmptyTexture : public FImageSource { public: FEmptyTexture (int lumpnum); @@ -67,7 +68,7 @@ FTexture *EmptyTexture_TryCreate(FileReader & file, int lumpnum) if (file.Read(check, 8) != 8) return NULL; if (memcmp(check, "\0\0\0\0\0\0\0\0", 8)) return NULL; - return new FEmptyTexture(lumpnum); + return new FImageTexture(new FEmptyTexture(lumpnum)); } //========================================================================== @@ -77,10 +78,11 @@ FTexture *EmptyTexture_TryCreate(FileReader & file, int lumpnum) //========================================================================== FEmptyTexture::FEmptyTexture (int lumpnum) -: FWorldTexture(NULL, lumpnum) +: FImageSource(lumpnum) { bMasked = true; Width = Height = 1; + bUseGamePalette = true; } //========================================================================== diff --git a/src/textures/formats/flattexture.cpp b/src/textures/formats/flattexture.cpp index 44a814d718..46b9e43fc1 100644 --- a/src/textures/formats/flattexture.cpp +++ b/src/textures/formats/flattexture.cpp @@ -38,6 +38,7 @@ #include "w_wad.h" #include "textures/textures.h" #include "imagehelpers.h" +#include "image.h" //========================================================================== // @@ -45,7 +46,7 @@ // //========================================================================== -class FFlatTexture : public FWorldTexture +class FFlatTexture : public FImageSource { public: FFlatTexture (int lumpnum); @@ -63,7 +64,7 @@ public: FTexture *FlatTexture_TryCreate(FileReader & file, int lumpnum) { - return new FFlatTexture(lumpnum); + return new FImageTexture(new FFlatTexture(lumpnum)); } //========================================================================== @@ -73,7 +74,7 @@ FTexture *FlatTexture_TryCreate(FileReader & file, int lumpnum) //========================================================================== FFlatTexture::FFlatTexture (int lumpnum) -: FWorldTexture(NULL, lumpnum) +: FImageSource(lumpnum) { int area; int bits; @@ -91,6 +92,7 @@ FFlatTexture::FFlatTexture (int lumpnum) case 256*256: bits = 8; break; } + bUseGamePalette = true; bMasked = false; bTranslucent = false; Width = Height = 1 << bits; diff --git a/src/textures/formats/imgztexture.cpp b/src/textures/formats/imgztexture.cpp index bc70f5e673..b87f4b63d1 100644 --- a/src/textures/formats/imgztexture.cpp +++ b/src/textures/formats/imgztexture.cpp @@ -39,6 +39,7 @@ #include "v_video.h" #include "bitmap.h" #include "imagehelpers.h" +#include "image.h" bool checkIMGZPalette(FileReader &file); @@ -50,7 +51,7 @@ bool checkIMGZPalette(FileReader &file); // //========================================================================== -class FIMGZTexture : public FWorldTexture +class FIMGZTexture : public FImageSource { struct ImageHeader { @@ -69,8 +70,6 @@ public: FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int16_t t, bool isalpha); TArray Get8BitPixels(bool alphatex) override; int CopyPixels(FBitmap *bmp) override; - - bool UseBasePalette() override { return !isalpha; } }; @@ -95,7 +94,7 @@ FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum) l = file.ReadInt16(); t = file.ReadInt16(); ispalette = checkIMGZPalette(file); - return new FIMGZTexture(lumpnum, w, h, l, t, !ispalette); + return new FImageTexture(new FIMGZTexture(lumpnum, w, h, l, t, !ispalette)); } //========================================================================== @@ -105,14 +104,14 @@ FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum) //========================================================================== FIMGZTexture::FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int16_t t, bool _isalpha) - : FWorldTexture(NULL, lumpnum) + : FImageSource(lumpnum) { - Wads.GetLumpName (Name, lumpnum); Width = w; Height = h; - _LeftOffset[1] = _LeftOffset[0] = l; - _TopOffset[1] = _TopOffset[0] = t; + LeftOffset = l; + TopOffset = t; isalpha = _isalpha; + bUseGamePalette = !isalpha; } //========================================================================== @@ -203,7 +202,7 @@ TArray FIMGZTexture::Get8BitPixels(bool alphatex) int FIMGZTexture::CopyPixels(FBitmap *bmp) { - if (!isalpha) return FTexture::CopyPixels(bmp); + if (!isalpha) return FImageSource::CopyPixels(bmp); else return CopyTranslatedPixels(bmp, translationtables[TRANSLATION_Standard][STD_Grayscale]->Palette); } diff --git a/src/textures/formats/jpegtexture.cpp b/src/textures/formats/jpegtexture.cpp index 5a39dc9e85..06b093e95e 100644 --- a/src/textures/formats/jpegtexture.cpp +++ b/src/textures/formats/jpegtexture.cpp @@ -46,6 +46,7 @@ extern "C" #include "bitmap.h" #include "v_video.h" #include "imagehelpers.h" +#include "image.h" struct FLumpSourceMgr : public jpeg_source_mgr @@ -179,13 +180,12 @@ void JPEG_OutputMessage (j_common_ptr cinfo) // //========================================================================== -class FJPEGTexture : public FWorldTexture +class FJPEGTexture : public FImageSource { public: FJPEGTexture (int lumpnum, int width, int height); int CopyPixels(FBitmap *bmp) override; - bool UseBasePalette() override; TArray Get8BitPixels(bool alphatex) override; }; @@ -236,7 +236,7 @@ FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum) { return NULL; } - return new FJPEGTexture (lumpnum, BigShort(first4bytes.w[1]), BigShort(first4bytes.w[0])); + return new FImageTexture(new FJPEGTexture (lumpnum, BigShort(first4bytes.w[1]), BigShort(first4bytes.w[0]))); } //========================================================================== @@ -246,9 +246,8 @@ FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum) //========================================================================== FJPEGTexture::FJPEGTexture (int lumpnum, int width, int height) -: FWorldTexture(NULL, lumpnum) +: FImageSource(lumpnum) { - UseType = ETextureType::MiscPatch; bMasked = false; Width = width; @@ -463,13 +462,3 @@ int FJPEGTexture::CopyPixels(FBitmap *bmp) return 0; } - -//=========================================================================== -// -// -//=========================================================================== - -bool FJPEGTexture::UseBasePalette() -{ - return false; -} diff --git a/src/textures/formats/multipatchtexture.cpp b/src/textures/formats/multipatchtexture.cpp index 63cffb95d9..42a9d78027 100644 --- a/src/textures/formats/multipatchtexture.cpp +++ b/src/textures/formats/multipatchtexture.cpp @@ -146,7 +146,7 @@ struct FPatchLookup // //========================================================================== -class FMultiPatchTexture : public FWorldTexture +class FMultiPatchTexture : public FTexture { public: FMultiPatchTexture (const void *texdef, FPatchLookup *patchlookup, int maxpatchnum, bool strife, int deflump); diff --git a/src/textures/formats/pcxtexture.cpp b/src/textures/formats/pcxtexture.cpp index 7a28dffb07..c755723e46 100644 --- a/src/textures/formats/pcxtexture.cpp +++ b/src/textures/formats/pcxtexture.cpp @@ -40,6 +40,7 @@ #include "bitmap.h" #include "v_video.h" #include "imagehelpers.h" +#include "image.h" //========================================================================== // @@ -79,13 +80,12 @@ struct PCXHeader // //========================================================================== -class FPCXTexture : public FWorldTexture +class FPCXTexture : public FImageSource { public: FPCXTexture (int lumpnum, PCXHeader &); int CopyPixels(FBitmap *bmp) override; - bool UseBasePalette() override; protected: void ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr); @@ -132,7 +132,7 @@ FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum) file.Seek(0, FileReader::SeekSet); file.Read(&hdr, sizeof(hdr)); - return new FPCXTexture(lumpnum, hdr); + return new FImageTexture(new FPCXTexture(lumpnum, hdr)); } //========================================================================== @@ -142,7 +142,7 @@ FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum) //========================================================================== FPCXTexture::FPCXTexture(int lumpnum, PCXHeader & hdr) -: FWorldTexture(NULL, lumpnum) +: FImageSource(lumpnum) { bMasked = false; Width = LittleShort(hdr.xmax) - LittleShort(hdr.xmin) + 1; @@ -513,13 +513,3 @@ int FPCXTexture::CopyPixels(FBitmap *bmp) return 0; } - -//=========================================================================== -// -// -//=========================================================================== - -bool FPCXTexture::UseBasePalette() -{ - return false; -} diff --git a/src/textures/formats/pngtexture.cpp b/src/textures/formats/pngtexture.cpp index cbdf6f3aae..91b70b7451 100644 --- a/src/textures/formats/pngtexture.cpp +++ b/src/textures/formats/pngtexture.cpp @@ -40,6 +40,7 @@ #include "m_png.h" #include "bitmap.h" #include "imagehelpers.h" +#include "image.h" //========================================================================== // @@ -47,7 +48,7 @@ // //========================================================================== -class FPNGTexture : public FWorldTexture +class FPNGTexture : public FImageSource { public: FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height, uint8_t bitdepth, uint8_t colortype, uint8_t interlace); @@ -141,7 +142,7 @@ FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum) } } - return new FPNGTexture (data, lumpnum, FString(), width, height, bitdepth, colortype, interlace); + return new FImageTexture(new FPNGTexture (data, lumpnum, FString(), width, height, bitdepth, colortype, interlace)); } //========================================================================== diff --git a/src/textures/formats/rawpagetexture.cpp b/src/textures/formats/rawpagetexture.cpp index 72ccecf265..9c38748e25 100644 --- a/src/textures/formats/rawpagetexture.cpp +++ b/src/textures/formats/rawpagetexture.cpp @@ -40,6 +40,7 @@ #include "bitmap.h" #include "textures/textures.h" #include "imagehelpers.h" +#include "image.h" //========================================================================== @@ -48,7 +49,7 @@ // //========================================================================== -class FRawPageTexture : public FWorldTexture +class FRawPageTexture : public FImageSource { int mPaletteLump = -1; public: @@ -73,9 +74,9 @@ static bool CheckIfRaw(FileReader & data) int height; int width; - foo = (patch_t *)M_Malloc (data.GetLength()); - data.Seek (0, FileReader::SeekSet); - data.Read (foo, data.GetLength()); + data.Seek(0, FileReader::SeekSet); + auto bits = data.Read(data.GetLength()); + foo = (patch_t *)bits.Data();; height = LittleShort(foo->height); width = LittleShort(foo->width); @@ -98,7 +99,6 @@ static bool CheckIfRaw(FileReader & data) } else if (ofs >= 64000-1) // Need one byte for an empty column { - M_Free (foo); return true; } else @@ -109,29 +109,24 @@ static bool CheckIfRaw(FileReader & data) { if (foo2[ofs] == 255) { - M_Free (foo); return true; } ofs += foo2[ofs+1] + 4; } if (ofs >= 64000) { - M_Free (foo); return true; } } } if (gapAtStart || (x != width)) { - M_Free (foo); return true; } - M_Free(foo); return false; } else { - M_Free (foo); return true; } } @@ -144,8 +139,8 @@ static bool CheckIfRaw(FileReader & data) FTexture *RawPageTexture_TryCreate(FileReader & file, int lumpnum) { - if (!CheckIfRaw(file)) return NULL; - return new FRawPageTexture(lumpnum); + if (!CheckIfRaw(file)) return nullptr; + return new FImageTexture(new FRawPageTexture(lumpnum)); } @@ -156,17 +151,20 @@ FTexture *RawPageTexture_TryCreate(FileReader & file, int lumpnum) //========================================================================== FRawPageTexture::FRawPageTexture (int lumpnum) -: FWorldTexture(NULL, lumpnum) +: FImageSource(lumpnum) { Width = 320; Height = 200; // Special case hack for Heretic's E2 end pic. This is not going to be exposed as an editing feature because the implications would be horrible. + FString Name; + Wads.GetLumpName(Name, lumpnum); if (Name.CompareNoCase("E2END") == 0 && gameinfo.gametype == GAME_Heretic) { mPaletteLump = Wads.CheckNumForName("E2PAL"); if (Wads.LumpLength(mPaletteLump) < 768) mPaletteLump = -1; } + else bUseGamePalette = true; } //========================================================================== @@ -206,7 +204,7 @@ TArray FRawPageTexture::Get8BitPixels(bool alphatex) int FRawPageTexture::CopyPixels(FBitmap *bmp) { - if (mPaletteLump < 0) return FTexture::CopyPixels(bmp); + if (mPaletteLump < 0) return FImageSource::CopyPixels(bmp); else { FMemLump lump = Wads.ReadLump(SourceLump); diff --git a/src/textures/formats/shadertexture.cpp b/src/textures/formats/shadertexture.cpp index e68fdf7e56..6f34437989 100644 --- a/src/textures/formats/shadertexture.cpp +++ b/src/textures/formats/shadertexture.cpp @@ -40,16 +40,16 @@ #include "w_wad.h" #include "bitmap.h" #include "imagehelpers.h" +#include "image.h" -class FBarShader : public FWorldTexture +class FBarShader : public FImageSource { public: FBarShader(bool vertical, bool reverse) { int i; - Name.Format("BarShader%c%c", vertical ? 'v' : 'h', reverse ? 'r' : 'f'); Width = vertical ? 2 : 256; Height = vertical ? 256 : 2; bMasked = false; @@ -126,12 +126,6 @@ public: return 0; } - bool UseBasePalette() override - { - return false; - } - - private: uint8_t Pixels[512]; }; @@ -139,5 +133,6 @@ private: FTexture *CreateShaderTexture(bool vertical, bool reverse) { - return new FBarShader(vertical, reverse); + FStringf name("BarShader%c%c", vertical ? 'v' : 'h', reverse ? 'r' : 'f'); + auto tex = new FImageTexture(new FBarShader(vertical, reverse), name.GetChars()); } diff --git a/src/textures/formats/tgatexture.cpp b/src/textures/formats/tgatexture.cpp index a97d26dbaa..9725fe6d1f 100644 --- a/src/textures/formats/tgatexture.cpp +++ b/src/textures/formats/tgatexture.cpp @@ -40,6 +40,7 @@ #include "bitmap.h" #include "v_video.h" #include "imagehelpers.h" +#include "image.h" //========================================================================== @@ -75,13 +76,12 @@ struct TGAHeader // //========================================================================== -class FTGATexture : public FWorldTexture +class FTGATexture : public FImageSource { public: FTGATexture (int lumpnum, TGAHeader *); int CopyPixels(FBitmap *bmp) override; - bool UseBasePalette() override; protected: void ReadCompressed(FileReader &lump, uint8_t * buffer, int bytesperpixel); @@ -119,7 +119,7 @@ FTexture *TGATexture_TryCreate(FileReader & file, int lumpnum) hdr.width = LittleShort(hdr.width); hdr.height = LittleShort(hdr.height); - return new FTGATexture(lumpnum, &hdr); + return new FImageTexture(new FTGATexture(lumpnum, &hdr)); } //========================================================================== @@ -129,9 +129,8 @@ FTexture *TGATexture_TryCreate(FileReader & file, int lumpnum) //========================================================================== FTGATexture::FTGATexture (int lumpnum, TGAHeader * hdr) -: FWorldTexture(NULL, lumpnum) +: FImageSource(lumpnum) { - Wads.GetLumpName (Name, lumpnum); Width = hdr->width; Height = hdr->height; // Alpha channel is used only for 32 bit RGBA and paletted images with RGBA palettes. @@ -534,13 +533,3 @@ int FTGATexture::CopyPixels(FBitmap *bmp) delete [] sbuffer; return transval; } - -//=========================================================================== -// -// -//=========================================================================== - -bool FTGATexture::UseBasePalette() -{ - return false; -} diff --git a/src/textures/formats/worldtexture.cpp b/src/textures/formats/worldtexture.cpp deleted file mode 100644 index 66b9ec3b4d..0000000000 --- a/src/textures/formats/worldtexture.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* -** worldtexture.cpp -** Intermediate class for some common code for several classes -** -**--------------------------------------------------------------------------- -** Copyright 2018 Christoph Oelckers -** All rights reserved. -** -** Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions -** are met: -** -** 1. Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** 2. Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in the -** documentation and/or other materials provided with the distribution. -** 3. The name of the author may not be used to endorse or promote products -** derived from this software without specific prior written permission. -** -** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -**--------------------------------------------------------------------------- -** -** -*/ - -#include "textures.h" - - -//========================================================================== -// -// -// -//========================================================================== - -FWorldTexture::FWorldTexture(const char *name, int lumpnum) - : FTexture(name, lumpnum) -{ -} - diff --git a/src/textures/image.h b/src/textures/image.h index e868c557df..7bcdb05102 100644 --- a/src/textures/image.h +++ b/src/textures/image.h @@ -81,12 +81,13 @@ public: // //========================================================================== -class FImageTexture : public FWorldTexture +class FImageTexture : public FTexture { FImageSource *mImage; public: - FImageTexture (FImageSource *image); + FImageTexture (FImageSource *image, const char *name = nullptr); virtual TArray Get8BitPixels(bool alphatex); + FImageSource *GetImage() const { return mImage; } bool UseBasePalette() override; diff --git a/src/textures/imagetexture.cpp b/src/textures/imagetexture.cpp index 00326664c7..7cb45887e1 100644 --- a/src/textures/imagetexture.cpp +++ b/src/textures/imagetexture.cpp @@ -48,8 +48,8 @@ // //========================================================================== -FImageTexture::FImageTexture(FImageSource *img) -: FWorldTexture(nullptr, img->LumpNum()) +FImageTexture::FImageTexture(FImageSource *img, const char *name) +: FWorldTexture(name, img->LumpNum()) { mImage = img; Wads.GetLumpName (Name, img->LumpNum()); diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index c8969d9782..0aec9d106f 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -49,8 +49,9 @@ #include "hwrenderer/textures/hw_ihwtexture.h" #include "swrenderer/textures/r_swtexture.h" #include "imagehelpers.h" +#include "image.h" -FTexture *CreateBrightmapTexture(FTexture*); +FTexture *CreateBrightmapTexture(FImageSource*); // Make sprite offset adjustment user-configurable per renderer. int r_spriteadjustSW, r_spriteadjustHW; @@ -537,7 +538,7 @@ void FTexture::CreateDefaultBrightmap() { // Create a brightmap DPrintf(DMSG_NOTIFY, "brightmap created for texture '%s'\n", Name.GetChars()); - Brightmap = CreateBrightmapTexture(this); + Brightmap = CreateBrightmapTexture(static_cast(this)->GetImage()); bBrightmapChecked = true; TexMan.AddTexture(Brightmap); return; diff --git a/src/textures/textures.h b/src/textures/textures.h index 46ef356011..199b7389da 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -670,14 +670,6 @@ public: }; -// base class for everything that can be used as a world texture. -// This intermediate class encapsulates the buffers for the software renderer. -class FWorldTexture : public FTexture -{ -protected: - FWorldTexture(const char *name = nullptr, int lumpnum = -1); -}; - // A texture that doesn't really exist class FDummyTexture : public FTexture {