- 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
|
|
@ -41,15 +41,54 @@
|
|||
#include "m_png.h"
|
||||
#include "bitmap.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// A PNG texture
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool FPNGTexture::Check(FileReader & file)
|
||||
class FPNGTexture : public FTexture
|
||||
{
|
||||
DWORD id;
|
||||
file.Seek(0, SEEK_SET);
|
||||
return file.Read(&id, 4) == 4 && id == MAKE_ID(137,'P','N','G');
|
||||
}
|
||||
public:
|
||||
FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height, BYTE bitdepth, BYTE colortype, BYTE interlace);
|
||||
~FPNGTexture ();
|
||||
|
||||
FTexture *FPNGTexture::Create(FileReader & data, int lumpnum)
|
||||
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
|
||||
const BYTE *GetPixels ();
|
||||
void Unload ();
|
||||
FTextureFormat GetFormat ();
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
|
||||
bool UseBasePalette();
|
||||
int GetSourceLump() { return SourceLump; }
|
||||
|
||||
protected:
|
||||
|
||||
int SourceLump;
|
||||
FString SourceFile;
|
||||
BYTE *Pixels;
|
||||
Span **Spans;
|
||||
|
||||
BYTE BitDepth;
|
||||
BYTE ColorType;
|
||||
BYTE Interlace;
|
||||
|
||||
BYTE *PaletteMap;
|
||||
int PaletteSize;
|
||||
DWORD StartOfIDAT;
|
||||
|
||||
void MakeTexture ();
|
||||
|
||||
friend class FTexture;
|
||||
};
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum)
|
||||
{
|
||||
union
|
||||
{
|
||||
|
|
@ -64,12 +103,15 @@ FTexture *FPNGTexture::Create(FileReader & data, int lumpnum)
|
|||
// This is most likely a PNG, but make sure. (Note that if the
|
||||
// first 4 bytes match, but later bytes don't, we assume it's
|
||||
// a corrupt PNG.)
|
||||
data.Seek(4, SEEK_SET);
|
||||
data.Read (first4bytes.b, 4);
|
||||
|
||||
data.Seek(0, SEEK_SET);
|
||||
if (data.Read (first4bytes.b, 4) != 4) return NULL;
|
||||
if (first4bytes.dw != MAKE_ID(137,'P','N','G')) return NULL;
|
||||
if (data.Read (first4bytes.b, 4) != 4) return NULL;
|
||||
if (first4bytes.dw != MAKE_ID(13,10,26,10)) return NULL;
|
||||
data.Read (first4bytes.b, 4);
|
||||
if (data.Read (first4bytes.b, 4) != 4) return NULL;
|
||||
if (first4bytes.dw != MAKE_ID(0,0,0,13)) return NULL;
|
||||
data.Read (first4bytes.b, 4);
|
||||
if (data.Read (first4bytes.b, 4) != 4) return NULL;
|
||||
if (first4bytes.dw != MAKE_ID('I','H','D','R')) return NULL;
|
||||
|
||||
// The PNG looks valid so far. Check the IHDR to make sure it's a
|
||||
|
|
@ -106,7 +148,13 @@ FTexture *FPNGTexture::Create(FileReader & data, int lumpnum)
|
|||
bitdepth, colortype, interlace);
|
||||
}
|
||||
|
||||
FTexture *FPNGTexture::CreateFromFile(PNGHandle *png, const FString &filename)
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename)
|
||||
{
|
||||
DWORD width, height;
|
||||
BYTE bitdepth, colortype, compression, filter, interlace;
|
||||
|
|
@ -137,6 +185,12 @@ FTexture *FPNGTexture::CreateFromFile(PNGHandle *png, const FString &filename)
|
|||
bitdepth, colortype, interlace);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height,
|
||||
BYTE depth, BYTE colortype, BYTE interlace)
|
||||
: SourceLump(lumpnum), SourceFile(filename), Pixels(0), Spans(0),
|
||||
|
|
@ -276,6 +330,12 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FPNGTexture::~FPNGTexture ()
|
||||
{
|
||||
Unload ();
|
||||
|
|
@ -291,6 +351,12 @@ FPNGTexture::~FPNGTexture ()
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FPNGTexture::Unload ()
|
||||
{
|
||||
if (Pixels != NULL)
|
||||
|
|
@ -300,6 +366,12 @@ void FPNGTexture::Unload ()
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FTextureFormat FPNGTexture::GetFormat()
|
||||
{
|
||||
#if 0
|
||||
|
|
@ -315,6 +387,12 @@ FTextureFormat FPNGTexture::GetFormat()
|
|||
#endif
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
const BYTE *FPNGTexture::GetColumn (unsigned int column, const Span **spans_out)
|
||||
{
|
||||
if (Pixels == NULL)
|
||||
|
|
@ -343,6 +421,12 @@ const BYTE *FPNGTexture::GetColumn (unsigned int column, const Span **spans_out)
|
|||
return Pixels + column*Height;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
const BYTE *FPNGTexture::GetPixels ()
|
||||
{
|
||||
if (Pixels == NULL)
|
||||
|
|
@ -352,6 +436,12 @@ const BYTE *FPNGTexture::GetPixels ()
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FPNGTexture::MakeTexture ()
|
||||
{
|
||||
FileReader *lump;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue