- Made all the basic texture classes local to their implementation.
They are not needed anywhere else. - Changed the HackHack hack for corrupt 256 pixel high textures that FMultiPatchTexture only calls a virtual function instead of doing any type checks of the patch itself. - Cleaned up the constant definitions in doomdata.h. - Moved the TEXTUREx structures from doomdata.h to multipatchtexture.cpp because they are used only in this one file. - Removed some more typedefs from r_defs.h and doomdata.h - Moved local polyobject data definitions from p_local.h to po_man.cpp. SVN r1012 (trunk)
This commit is contained in:
parent
71b0d4d074
commit
47aacc45c8
34 changed files with 1723 additions and 1091 deletions
|
|
@ -95,6 +95,12 @@
|
|||
#define DDSCAPS2_CUBEMAP_NEGATIZEZ 0x00008000
|
||||
#define DDSCAPS2_VOLUME 0x00200000
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
struct DDPIXELFORMAT
|
||||
{
|
||||
DWORD Size; // Must be 32
|
||||
|
|
@ -136,7 +142,62 @@ struct DDSFileHeader
|
|||
DDSURFACEDESC2 Desc;
|
||||
};
|
||||
|
||||
bool FDDSTexture::Check (FileReader &file)
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// A DDS image, with DXTx compression
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
class FDDSTexture : public FTexture
|
||||
{
|
||||
public:
|
||||
FDDSTexture (FileReader &lump, int lumpnum, void *surfdesc);
|
||||
~FDDSTexture ();
|
||||
|
||||
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
|
||||
const BYTE *GetPixels ();
|
||||
void Unload ();
|
||||
FTextureFormat GetFormat ();
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
|
||||
int SourceLump;
|
||||
BYTE *Pixels;
|
||||
Span **Spans;
|
||||
|
||||
DWORD Format;
|
||||
|
||||
DWORD RMask, GMask, BMask, AMask;
|
||||
BYTE RShiftL, GShiftL, BShiftL, AShiftL;
|
||||
BYTE RShiftR, GShiftR, BShiftR, AShiftR;
|
||||
|
||||
SDWORD Pitch;
|
||||
DWORD LinearSize;
|
||||
|
||||
static void CalcBitShift (DWORD mask, BYTE *lshift, BYTE *rshift);
|
||||
|
||||
void MakeTexture ();
|
||||
void ReadRGB (FWadLump &lump, BYTE *tcbuf = NULL);
|
||||
void DecompressDXT1 (FWadLump &lump, BYTE *tcbuf = NULL);
|
||||
void DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbuf = NULL);
|
||||
void DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbuf = NULL);
|
||||
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
|
||||
friend class FTexture;
|
||||
};
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static bool CheckDDS (FileReader &file)
|
||||
{
|
||||
DDSFileHeader Header;
|
||||
|
||||
|
|
@ -153,7 +214,13 @@ bool FDDSTexture::Check (FileReader &file)
|
|||
Header.Desc.Height != 0;
|
||||
}
|
||||
|
||||
FTexture *FDDSTexture::Create (FileReader &data, int lumpnum)
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
|
@ -161,6 +228,8 @@ FTexture *FDDSTexture::Create (FileReader &data, int lumpnum)
|
|||
DWORD byteswapping[sizeof(DDSURFACEDESC2) / 4];
|
||||
};
|
||||
|
||||
if (!CheckDDS(data)) return NULL;
|
||||
|
||||
data.Seek (4, SEEK_SET);
|
||||
data.Read (&surfdesc, sizeof(surfdesc));
|
||||
|
||||
|
|
@ -209,6 +278,12 @@ FTexture *FDDSTexture::Create (FileReader &data, int lumpnum)
|
|||
return new FDDSTexture (data, lumpnum, &surfdesc);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc)
|
||||
: SourceLump(lumpnum), Pixels(0), Spans(0)
|
||||
{
|
||||
|
|
@ -259,6 +334,8 @@ FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc)
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Returns the number of bits the color must be shifted to produce
|
||||
// an 8-bit value, as in:
|
||||
//
|
||||
|
|
@ -269,6 +346,9 @@ FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc)
|
|||
// For any color of at least 4 bits, this ensures that the result
|
||||
// of the calculation for c will be fully saturated, given a maximum
|
||||
// value for the input bit mask.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::CalcBitShift (DWORD mask, BYTE *lshiftp, BYTE *rshiftp)
|
||||
{
|
||||
BYTE shift;
|
||||
|
|
@ -296,6 +376,12 @@ void FDDSTexture::CalcBitShift (DWORD mask, BYTE *lshiftp, BYTE *rshiftp)
|
|||
*rshiftp = shift;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FDDSTexture::~FDDSTexture ()
|
||||
{
|
||||
Unload ();
|
||||
|
|
@ -306,6 +392,12 @@ FDDSTexture::~FDDSTexture ()
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::Unload ()
|
||||
{
|
||||
if (Pixels != NULL)
|
||||
|
|
@ -315,6 +407,12 @@ void FDDSTexture::Unload ()
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FTextureFormat FDDSTexture::GetFormat()
|
||||
{
|
||||
#if 0
|
||||
|
|
@ -333,6 +431,12 @@ FTextureFormat FDDSTexture::GetFormat()
|
|||
#endif
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
const BYTE *FDDSTexture::GetColumn (unsigned int column, const Span **spans_out)
|
||||
{
|
||||
if (Pixels == NULL)
|
||||
|
|
@ -361,6 +465,12 @@ const BYTE *FDDSTexture::GetColumn (unsigned int column, const Span **spans_out)
|
|||
return Pixels + column*Height;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
const BYTE *FDDSTexture::GetPixels ()
|
||||
{
|
||||
if (Pixels == NULL)
|
||||
|
|
@ -370,6 +480,12 @@ const BYTE *FDDSTexture::GetPixels ()
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::MakeTexture ()
|
||||
{
|
||||
FWadLump lump = Wads.OpenLumpNum (SourceLump);
|
||||
|
|
@ -396,6 +512,12 @@ void FDDSTexture::MakeTexture ()
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf)
|
||||
{
|
||||
DWORD x, y;
|
||||
|
|
@ -459,6 +581,12 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf)
|
|||
delete[] linebuff;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
|
||||
{
|
||||
const long blocklinelen = ((Width + 3) >> 2) << 3;
|
||||
|
|
@ -550,8 +678,12 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf)
|
|||
delete[] blockbuff;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DXT3: Decompression is identical to DXT1, except every 64-bit block is
|
||||
// preceded by another 64-bit block with explicit alpha values.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbuf)
|
||||
{
|
||||
|
|
@ -628,8 +760,12 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu
|
|||
delete[] blockbuff;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// DXT5: Decompression is identical to DXT3, except every 64-bit alpha block
|
||||
// contains interpolated alpha values, similar to the 64-bit color block.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbuf)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue