mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-21 11:31:41 +00:00
- moved image format detection logic from FTexture to FImageSource.
This commit is contained in:
parent
34884e2756
commit
5448874c6e
18 changed files with 145 additions and 108 deletions
|
@ -64,11 +64,11 @@ public:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture *AutomapTexture_TryCreate(FileReader &data, int lumpnum)
|
FImageSource *AutomapImage_TryCreate(FileReader &data, int lumpnum)
|
||||||
{
|
{
|
||||||
if (data.GetLength() < 320) return nullptr;
|
if (data.GetLength() < 320) return nullptr;
|
||||||
if (!Wads.CheckLumpName(lumpnum, "AUTOPAGE")) return nullptr;
|
if (!Wads.CheckLumpName(lumpnum, "AUTOPAGE")) return nullptr;
|
||||||
return new FImageTexture(new FAutomapTexture(lumpnum));
|
return new FAutomapTexture(lumpnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -218,7 +218,7 @@ static bool CheckDDS (FileReader &file)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum)
|
FImageSource *DDSImage_TryCreate (FileReader &data, int lumpnum)
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -273,7 +273,7 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return new FImageTexture(new FDDSTexture (data, lumpnum, &surfdesc));
|
return new FDDSTexture (data, lumpnum, &surfdesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture *EmptyTexture_TryCreate(FileReader & file, int lumpnum)
|
FImageSource *EmptyImage_TryCreate(FileReader & file, int lumpnum)
|
||||||
{
|
{
|
||||||
char check[8];
|
char check[8];
|
||||||
if (file.GetLength() != 8) return NULL;
|
if (file.GetLength() != 8) return NULL;
|
||||||
|
@ -68,7 +68,7 @@ FTexture *EmptyTexture_TryCreate(FileReader & file, int lumpnum)
|
||||||
if (file.Read(check, 8) != 8) return NULL;
|
if (file.Read(check, 8) != 8) return NULL;
|
||||||
if (memcmp(check, "\0\0\0\0\0\0\0\0", 8)) return NULL;
|
if (memcmp(check, "\0\0\0\0\0\0\0\0", 8)) return NULL;
|
||||||
|
|
||||||
return new FImageTexture(new FEmptyTexture(lumpnum));
|
return new FEmptyTexture(lumpnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -62,9 +62,9 @@ public:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture *FlatTexture_TryCreate(FileReader & file, int lumpnum)
|
FImageSource *FlatImage_TryCreate(FileReader & file, int lumpnum)
|
||||||
{
|
{
|
||||||
return new FImageTexture(new FFlatTexture(lumpnum));
|
return new FFlatTexture(lumpnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum)
|
FImageSource *IMGZImage_TryCreate(FileReader & file, int lumpnum)
|
||||||
{
|
{
|
||||||
uint32_t magic = 0;
|
uint32_t magic = 0;
|
||||||
uint16_t w, h;
|
uint16_t w, h;
|
||||||
|
@ -94,7 +94,7 @@ FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum)
|
||||||
l = file.ReadInt16();
|
l = file.ReadInt16();
|
||||||
t = file.ReadInt16();
|
t = file.ReadInt16();
|
||||||
ispalette = checkIMGZPalette(file);
|
ispalette = checkIMGZPalette(file);
|
||||||
return new FImageTexture(new FIMGZTexture(lumpnum, w, h, l, t, !ispalette));
|
return new FIMGZTexture(lumpnum, w, h, l, t, !ispalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -195,7 +195,7 @@ public:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum)
|
FImageSource *JPEGImage_TryCreate(FileReader & data, int lumpnum)
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -236,7 +236,7 @@ FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return new FImageTexture(new FJPEGTexture (lumpnum, BigShort(first4bytes.w[1]), BigShort(first4bytes.w[0])));
|
return new FJPEGTexture (lumpnum, BigShort(first4bytes.w[1]), BigShort(first4bytes.w[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -125,7 +125,7 @@ static bool CheckIfPatch(FileReader & file, bool &isalpha)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture *PatchTexture_TryCreate(FileReader & file, int lumpnum)
|
FImageSource *PatchImage_TryCreate(FileReader & file, int lumpnum)
|
||||||
{
|
{
|
||||||
patch_t header;
|
patch_t header;
|
||||||
bool isalpha;
|
bool isalpha;
|
||||||
|
@ -136,7 +136,7 @@ FTexture *PatchTexture_TryCreate(FileReader & file, int lumpnum)
|
||||||
header.height = file.ReadUInt16();
|
header.height = file.ReadUInt16();
|
||||||
header.leftoffset = file.ReadInt16();
|
header.leftoffset = file.ReadInt16();
|
||||||
header.topoffset = file.ReadInt16();
|
header.topoffset = file.ReadInt16();
|
||||||
return new FImageTexture(new FPatchTexture(lumpnum, &header, isalpha));
|
return new FPatchTexture(lumpnum, &header, isalpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -103,7 +103,7 @@ protected:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum)
|
FImageSource * PCXImage_TryCreate(FileReader & file, int lumpnum)
|
||||||
{
|
{
|
||||||
PCXHeader hdr;
|
PCXHeader hdr;
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ FTexture * PCXTexture_TryCreate(FileReader & file, int lumpnum)
|
||||||
file.Seek(0, FileReader::SeekSet);
|
file.Seek(0, FileReader::SeekSet);
|
||||||
file.Read(&hdr, sizeof(hdr));
|
file.Read(&hdr, sizeof(hdr));
|
||||||
|
|
||||||
return new FImageTexture(new FPCXTexture(lumpnum, hdr));
|
return new FPCXTexture(lumpnum, hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -82,7 +82,7 @@ protected:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum)
|
FImageSource *PNGImage_TryCreate(FileReader & data, int lumpnum)
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
|
@ -141,7 +141,7 @@ FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new FImageTexture(new FPNGTexture (data, lumpnum, FString(), width, height, bitdepth, colortype, interlace));
|
return new FPNGTexture (data, lumpnum, FString(), width, height, bitdepth, colortype, interlace);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -137,10 +137,10 @@ static bool CheckIfRaw(FileReader & data)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture *RawPageTexture_TryCreate(FileReader & file, int lumpnum)
|
FImageSource *RawPageImage_TryCreate(FileReader & file, int lumpnum)
|
||||||
{
|
{
|
||||||
if (!CheckIfRaw(file)) return nullptr;
|
if (!CheckIfRaw(file)) return nullptr;
|
||||||
return new FImageTexture(new FRawPageTexture(lumpnum));
|
return new FRawPageTexture(lumpnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ protected:
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FTexture *TGATexture_TryCreate(FileReader & file, int lumpnum)
|
FImageSource *TGAImage_TryCreate(FileReader & file, int lumpnum)
|
||||||
{
|
{
|
||||||
TGAHeader hdr;
|
TGAHeader hdr;
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ FTexture *TGATexture_TryCreate(FileReader & file, int lumpnum)
|
||||||
hdr.width = LittleShort(hdr.width);
|
hdr.width = LittleShort(hdr.width);
|
||||||
hdr.height = LittleShort(hdr.height);
|
hdr.height = LittleShort(hdr.height);
|
||||||
|
|
||||||
return new FImageTexture(new FTGATexture(lumpnum, &hdr));
|
return new FTGATexture(lumpnum, &hdr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -367,8 +367,7 @@ unsigned char *FTexture::LoadHiresTexture(int *width, int *height)
|
||||||
|
|
||||||
if (HiresLump >= 0)
|
if (HiresLump >= 0)
|
||||||
{
|
{
|
||||||
HiresTexture = FTexture::CreateTexture(HiresLump, ETextureType::Any);
|
HiresTexture = FTexture::CreateTexture("", HiresLump, ETextureType::Any);
|
||||||
HiresTexture->Name = "";
|
|
||||||
TexMan.AddTexture(HiresTexture); // let the texture manager manage this.
|
TexMan.AddTexture(HiresTexture); // let the texture manager manage this.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,13 @@
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
|
#include "w_wad.h"
|
||||||
|
#include "files.h"
|
||||||
|
|
||||||
FMemArena FImageSource::ImageArena(32768);
|
FMemArena FImageSource::ImageArena(32768);
|
||||||
|
TArray<FImageSource *>FImageSource::ImageForLump;
|
||||||
|
int FImageSource::NextID;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// the default just returns an empty texture.
|
// the default just returns an empty texture.
|
||||||
|
@ -82,3 +87,78 @@ int FImageSource::CopyTranslatedPixels(FBitmap *bmp, PalEntry *remap)
|
||||||
bmp->CopyPixelData(0, 0, ppix.Data(), Width, Height, Height, 1, 0, remap, nullptr);
|
bmp->CopyPixelData(0, 0, ppix.Data(), Width, Height, Height, 1, 0, remap, nullptr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
typedef FImageSource * (*CreateFunc)(FileReader & file, int lumpnum);
|
||||||
|
|
||||||
|
struct TexCreateInfo
|
||||||
|
{
|
||||||
|
CreateFunc TryCreate;
|
||||||
|
ETextureType usetype;
|
||||||
|
};
|
||||||
|
|
||||||
|
FImageSource *IMGZImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
FImageSource *PNGImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
FImageSource *JPEGImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
FImageSource *DDSImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
FImageSource *PCXImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
FImageSource *TGAImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
FImageSource *RawPageImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
FImageSource *FlatImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
FImageSource *PatchImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
FImageSource *EmptyImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
FImageSource *AutomapImage_TryCreate(FileReader &, int lumpnum);
|
||||||
|
|
||||||
|
|
||||||
|
// Examines the lump contents to decide what type of texture to create,
|
||||||
|
// and creates the texture.
|
||||||
|
FImageSource * FImageSource::GetImage(int lumpnum, ETextureType usetype)
|
||||||
|
{
|
||||||
|
static TexCreateInfo CreateInfo[] = {
|
||||||
|
{ IMGZImage_TryCreate, ETextureType::Any },
|
||||||
|
{ PNGImage_TryCreate, ETextureType::Any },
|
||||||
|
{ JPEGImage_TryCreate, ETextureType::Any },
|
||||||
|
{ DDSImage_TryCreate, ETextureType::Any },
|
||||||
|
{ PCXImage_TryCreate, ETextureType::Any },
|
||||||
|
{ TGAImage_TryCreate, ETextureType::Any },
|
||||||
|
{ RawPageImage_TryCreate, ETextureType::MiscPatch },
|
||||||
|
{ FlatImage_TryCreate, ETextureType::Flat },
|
||||||
|
{ PatchImage_TryCreate, ETextureType::Any },
|
||||||
|
{ EmptyImage_TryCreate, ETextureType::Any },
|
||||||
|
{ AutomapImage_TryCreate, ETextureType::MiscPatch },
|
||||||
|
};
|
||||||
|
|
||||||
|
if (lumpnum == -1) return nullptr;
|
||||||
|
|
||||||
|
unsigned size = ImageForLump.Size();
|
||||||
|
if (size <= (unsigned)lumpnum)
|
||||||
|
{
|
||||||
|
// Hires textures can be added dynamically to the end of the lump array, so this must be checked each time.
|
||||||
|
ImageForLump.Resize(lumpnum + 1);
|
||||||
|
for (; size < ImageForLump.Size(); size++) ImageForLump[size] = nullptr;
|
||||||
|
}
|
||||||
|
// An image for this lump already exists. We do not need another one.
|
||||||
|
if (ImageForLump[lumpnum] != nullptr) return ImageForLump[lumpnum];
|
||||||
|
|
||||||
|
auto data = Wads.OpenLumpReader(lumpnum);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < countof(CreateInfo); i++)
|
||||||
|
{
|
||||||
|
if ((CreateInfo[i].usetype == usetype || CreateInfo[i].usetype == ETextureType::Any))
|
||||||
|
{
|
||||||
|
auto image = CreateInfo[i].TryCreate(data, lumpnum);
|
||||||
|
if (image != nullptr)
|
||||||
|
{
|
||||||
|
ImageForLump[lumpnum] = image;
|
||||||
|
return image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
|
@ -14,10 +14,14 @@ class FImageSource
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
static FMemArena ImageArena;
|
static FMemArena ImageArena;
|
||||||
|
static TArray<FImageSource *>ImageForLump;
|
||||||
|
static int NextID;
|
||||||
|
|
||||||
int SourceLump;
|
int SourceLump;
|
||||||
int Width = 0, Height = 0;
|
int Width = 0, Height = 0;
|
||||||
int LeftOffset = 0, TopOffset = 0; // Offsets stored in the image.
|
int LeftOffset = 0, TopOffset = 0; // Offsets stored in the image.
|
||||||
bool bUseGamePalette = false; // true if this is an image without its own color set.
|
bool bUseGamePalette = false; // true if this is an image without its own color set.
|
||||||
|
int ImageID = -1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -41,8 +45,9 @@ public:
|
||||||
virtual TArray<uint8_t> GetPalettedPixels(int conversion); // 'noremap0' will only be looked at by FPatchTexture and forwarded by FMultipatchTexture.
|
virtual TArray<uint8_t> GetPalettedPixels(int conversion); // 'noremap0' will only be looked at by FPatchTexture and forwarded by FMultipatchTexture.
|
||||||
virtual int CopyPixels(FBitmap *bmp, int conversion); // This will always ignore 'luminance'.
|
virtual int CopyPixels(FBitmap *bmp, int conversion); // This will always ignore 'luminance'.
|
||||||
int CopyTranslatedPixels(FBitmap *bmp, PalEntry *remap);
|
int CopyTranslatedPixels(FBitmap *bmp, PalEntry *remap);
|
||||||
static void ClearImages() { ImageArena.FreeAll(); }
|
static void ClearImages() { ImageArena.FreeAll(); ImageForLump.Clear(); NextID = 0; }
|
||||||
|
static FImageSource * FImageSource::GetImage(int lumpnum, ETextureType usetype);
|
||||||
|
|
||||||
// Conversion option
|
// Conversion option
|
||||||
enum EType
|
enum EType
|
||||||
{
|
{
|
||||||
|
@ -51,7 +56,7 @@ public:
|
||||||
noremap0 = 2
|
noremap0 = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
FImageSource(int sourcelump = -1) : SourceLump(sourcelump) {}
|
FImageSource(int sourcelump = -1) : SourceLump(sourcelump) { ImageID = ++NextID; }
|
||||||
virtual ~FImageSource() {}
|
virtual ~FImageSource() {}
|
||||||
|
|
||||||
// Creates an image from the given lump.
|
// Creates an image from the given lump.
|
||||||
|
|
|
@ -85,91 +85,45 @@ void FTexture::InitGrayMap()
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
typedef FTexture * (*CreateFunc)(FileReader & file, int lumpnum);
|
|
||||||
|
|
||||||
struct TexCreateInfo
|
|
||||||
{
|
|
||||||
CreateFunc TryCreate;
|
|
||||||
ETextureType usetype;
|
|
||||||
};
|
|
||||||
|
|
||||||
FTexture *IMGZTexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
FTexture *PNGTexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
FTexture *JPEGTexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
FTexture *DDSTexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
FTexture *PCXTexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
FTexture *TGATexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
FTexture *RawPageTexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
FTexture *FlatTexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
FTexture *PatchTexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
FTexture *EmptyTexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
FTexture *AutomapTexture_TryCreate(FileReader &, int lumpnum);
|
|
||||||
|
|
||||||
|
|
||||||
// Examines the lump contents to decide what type of texture to create,
|
// Examines the lump contents to decide what type of texture to create,
|
||||||
// and creates the texture.
|
// and creates the texture.
|
||||||
FTexture * FTexture::CreateTexture (int lumpnum, ETextureType usetype)
|
FTexture * FTexture::CreateTexture(const char *name, int lumpnum, ETextureType usetype)
|
||||||
{
|
{
|
||||||
static TexCreateInfo CreateInfo[]={
|
if (lumpnum == -1) return nullptr;
|
||||||
{ IMGZTexture_TryCreate, ETextureType::Any },
|
|
||||||
{ PNGTexture_TryCreate, ETextureType::Any },
|
|
||||||
{ JPEGTexture_TryCreate, ETextureType::Any },
|
|
||||||
{ DDSTexture_TryCreate, ETextureType::Any },
|
|
||||||
{ PCXTexture_TryCreate, ETextureType::Any },
|
|
||||||
{ TGATexture_TryCreate, ETextureType::Any },
|
|
||||||
{ RawPageTexture_TryCreate, ETextureType::MiscPatch },
|
|
||||||
{ FlatTexture_TryCreate, ETextureType::Flat },
|
|
||||||
{ PatchTexture_TryCreate, ETextureType::Any },
|
|
||||||
{ EmptyTexture_TryCreate, ETextureType::Any },
|
|
||||||
{ AutomapTexture_TryCreate, ETextureType::MiscPatch },
|
|
||||||
};
|
|
||||||
|
|
||||||
if (lumpnum == -1) return NULL;
|
auto image = FImageSource::GetImage(lumpnum, usetype);
|
||||||
|
if (image != nullptr)
|
||||||
auto data = Wads.OpenLumpReader (lumpnum);
|
|
||||||
|
|
||||||
for(size_t i = 0; i < countof(CreateInfo); i++)
|
|
||||||
{
|
{
|
||||||
if ((CreateInfo[i].usetype == usetype || CreateInfo[i].usetype == ETextureType::Any))
|
FTexture *tex = new FImageTexture(image);
|
||||||
|
if (tex != nullptr)
|
||||||
{
|
{
|
||||||
FTexture * tex = CreateInfo[i].TryCreate(data, lumpnum);
|
tex->UseType = usetype;
|
||||||
if (tex != NULL)
|
if (usetype == ETextureType::Flat)
|
||||||
{
|
{
|
||||||
tex->UseType = usetype;
|
int w = tex->GetWidth();
|
||||||
if (usetype == ETextureType::Flat)
|
int h = tex->GetHeight();
|
||||||
{
|
|
||||||
int w = tex->GetWidth();
|
|
||||||
int h = tex->GetHeight();
|
|
||||||
|
|
||||||
// Auto-scale flats with dimensions 128x128 and 256x256.
|
// Auto-scale flats with dimensions 128x128 and 256x256.
|
||||||
// In hindsight, a bad idea, but RandomLag made it sound better than it really is.
|
// In hindsight, a bad idea, but RandomLag made it sound better than it really is.
|
||||||
// Now we're stuck with this stupid behaviour.
|
// Now we're stuck with this stupid behaviour.
|
||||||
if (w==128 && h==128)
|
if (w==128 && h==128)
|
||||||
{
|
{
|
||||||
tex->Scale.X = tex->Scale.Y = 2;
|
tex->Scale.X = tex->Scale.Y = 2;
|
||||||
tex->bWorldPanning = true;
|
tex->bWorldPanning = true;
|
||||||
}
|
}
|
||||||
else if (w==256 && h==256)
|
else if (w==256 && h==256)
|
||||||
{
|
{
|
||||||
tex->Scale.X = tex->Scale.Y = 4;
|
tex->Scale.X = tex->Scale.Y = 4;
|
||||||
tex->bWorldPanning = true;
|
tex->bWorldPanning = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return tex;
|
|
||||||
}
|
}
|
||||||
|
tex->Name = name;
|
||||||
|
tex->Name.ToUpper();
|
||||||
|
return tex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
|
||||||
|
|
||||||
FTexture * FTexture::CreateTexture (const char *name, int lumpnum, ETextureType usetype)
|
|
||||||
{
|
|
||||||
FTexture *tex = CreateTexture(lumpnum, usetype);
|
|
||||||
if (tex != NULL && name != NULL) {
|
|
||||||
tex->Name = name;
|
|
||||||
tex->Name.ToUpper();
|
|
||||||
}
|
|
||||||
return tex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -412,7 +412,9 @@ FTextureID FTextureManager::CreateTexture (int lumpnum, ETextureType usetype)
|
||||||
{
|
{
|
||||||
if (lumpnum != -1)
|
if (lumpnum != -1)
|
||||||
{
|
{
|
||||||
FTexture *out = FTexture::CreateTexture(lumpnum, usetype);
|
FString str;
|
||||||
|
Wads.GetLumpName(str, lumpnum);
|
||||||
|
FTexture *out = FTexture::CreateTexture(str, lumpnum, usetype);
|
||||||
|
|
||||||
if (out != NULL) return AddTexture (out);
|
if (out != NULL) return AddTexture (out);
|
||||||
else
|
else
|
||||||
|
@ -559,7 +561,7 @@ void FTextureManager::AddHiresTextures (int wadnum)
|
||||||
if (amount == 0)
|
if (amount == 0)
|
||||||
{
|
{
|
||||||
// A texture with this name does not yet exist
|
// A texture with this name does not yet exist
|
||||||
FTexture * newtex = FTexture::CreateTexture (firsttx, ETextureType::Any);
|
FTexture * newtex = FTexture::CreateTexture (Name, firsttx, ETextureType::Any);
|
||||||
if (newtex != NULL)
|
if (newtex != NULL)
|
||||||
{
|
{
|
||||||
newtex->UseType=ETextureType::Override;
|
newtex->UseType=ETextureType::Override;
|
||||||
|
@ -570,7 +572,7 @@ void FTextureManager::AddHiresTextures (int wadnum)
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < tlist.Size(); i++)
|
for(unsigned int i = 0; i < tlist.Size(); i++)
|
||||||
{
|
{
|
||||||
FTexture * newtex = FTexture::CreateTexture (firsttx, ETextureType::Any);
|
FTexture * newtex = FTexture::CreateTexture ("", firsttx, ETextureType::Any);
|
||||||
if (newtex != NULL)
|
if (newtex != NULL)
|
||||||
{
|
{
|
||||||
FTexture * oldtex = Textures[tlist[i].GetIndex()].Texture;
|
FTexture * oldtex = Textures[tlist[i].GetIndex()].Texture;
|
||||||
|
@ -669,7 +671,7 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build
|
||||||
(sl=oldtex->GetSourceLump()) >= 0 && Wads.GetLumpNamespace(sl) == ns_sprites)
|
(sl=oldtex->GetSourceLump()) >= 0 && Wads.GetLumpNamespace(sl) == ns_sprites)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
FTexture * newtex = FTexture::CreateTexture (lumpnum, ETextureType::Any);
|
FTexture * newtex = FTexture::CreateTexture ("", lumpnum, ETextureType::Any);
|
||||||
if (newtex != NULL)
|
if (newtex != NULL)
|
||||||
{
|
{
|
||||||
// Replace the entire texture and adjust the scaling and offset factors.
|
// Replace the entire texture and adjust the scaling and offset factors.
|
||||||
|
@ -708,14 +710,13 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build
|
||||||
|
|
||||||
if (lumpnum>=0)
|
if (lumpnum>=0)
|
||||||
{
|
{
|
||||||
FTexture *newtex = FTexture::CreateTexture(lumpnum, ETextureType::Override);
|
FTexture *newtex = FTexture::CreateTexture(src, lumpnum, ETextureType::Override);
|
||||||
|
|
||||||
if (newtex != NULL)
|
if (newtex != NULL)
|
||||||
{
|
{
|
||||||
// Replace the entire texture and adjust the scaling and offset factors.
|
// Replace the entire texture and adjust the scaling and offset factors.
|
||||||
newtex->bWorldPanning = true;
|
newtex->bWorldPanning = true;
|
||||||
newtex->SetScaledSize(width, height);
|
newtex->SetScaledSize(width, height);
|
||||||
newtex->Name = src;
|
|
||||||
|
|
||||||
FTextureID oldtex = TexMan.CheckForTexture(src, ETextureType::MiscPatch);
|
FTextureID oldtex = TexMan.CheckForTexture(src, ETextureType::MiscPatch);
|
||||||
if (oldtex.isValid())
|
if (oldtex.isValid())
|
||||||
|
@ -911,7 +912,7 @@ void FTextureManager::AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &b
|
||||||
|
|
||||||
// Try to create a texture from this lump and add it.
|
// Try to create a texture from this lump and add it.
|
||||||
// Unfortunately we have to look at everything that comes through here...
|
// Unfortunately we have to look at everything that comes through here...
|
||||||
FTexture *out = FTexture::CreateTexture(i, skin ? ETextureType::SkinGraphic : ETextureType::MiscPatch);
|
FTexture *out = FTexture::CreateTexture(Name, i, skin ? ETextureType::SkinGraphic : ETextureType::MiscPatch);
|
||||||
|
|
||||||
if (out != NULL)
|
if (out != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -252,7 +252,6 @@ class FTexture
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static FTexture *CreateTexture(const char *name, int lumpnum, ETextureType usetype);
|
static FTexture *CreateTexture(const char *name, int lumpnum, ETextureType usetype);
|
||||||
static FTexture *CreateTexture(int lumpnum, ETextureType usetype);
|
|
||||||
virtual ~FTexture ();
|
virtual ~FTexture ();
|
||||||
virtual FImageSource *GetImage() const { return nullptr; }
|
virtual FImageSource *GetImage() const { return nullptr; }
|
||||||
void AddAutoMaterials();
|
void AddAutoMaterials();
|
||||||
|
|
|
@ -180,7 +180,6 @@ public:
|
||||||
int GetNumWads () const;
|
int GetNumWads () const;
|
||||||
|
|
||||||
int AddExternalFile(const char *filename);
|
int AddExternalFile(const char *filename);
|
||||||
int AddData(const char *filename, int length);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue