mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-22 20:21:26 +00:00
Fixed a few problems with the new texture code.
SVN r301 (trunk)
This commit is contained in:
parent
2536eca01d
commit
93beb4d42e
3 changed files with 20 additions and 17 deletions
|
@ -1,4 +1,3 @@
|
|||
|
||||
// Emacs style mode select -*- C++ -*-
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -207,17 +206,21 @@ int FTextureManager::AddTexture (FTexture *texture)
|
|||
return trans;
|
||||
}
|
||||
|
||||
// Calls DoCreateTexture and adds the texture to the manager.
|
||||
// Calls FTexture::CreateTexture and adds the texture to the manager.
|
||||
int FTextureManager::CreateTexture (int lumpnum, int usetype)
|
||||
{
|
||||
FTexture *out = FTexture::CreateTexture(lumpnum, usetype);
|
||||
|
||||
if (out != NULL) return AddTexture (out);
|
||||
else
|
||||
if (lumpnum != -1)
|
||||
{
|
||||
Printf (TEXTCOLOR_ORANGE "Invalid data encountered for texture %s\n", Wads.GetLumpFullName(lumpnum));
|
||||
return -1;
|
||||
FTexture *out = FTexture::CreateTexture(lumpnum, usetype);
|
||||
|
||||
if (out != NULL) return AddTexture (out);
|
||||
else
|
||||
{
|
||||
Printf (TEXTCOLOR_ORANGE "Invalid data encountered for texture %s\n", Wads.GetLumpFullName(lumpnum));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void FTextureManager::ReplaceTexture (int picnum, FTexture *newtexture, bool free)
|
||||
|
|
|
@ -287,7 +287,9 @@ protected:
|
|||
friend class FTexture;
|
||||
};
|
||||
|
||||
// A texture that is just a single patch
|
||||
// A TGA texture
|
||||
struct TGAHeader;
|
||||
|
||||
class FTGATexture : public FTexture
|
||||
{
|
||||
public:
|
||||
|
@ -304,7 +306,7 @@ protected:
|
|||
|
||||
static bool Check(FileReader & file);
|
||||
static FTexture *Create(FileReader & file, int lumpnum);
|
||||
FTGATexture (int lumpnum, int width, int height);
|
||||
FTGATexture (int lumpnum, TGAHeader *);
|
||||
void ReadCompressed(FileReader &lump, BYTE * buffer, int bytesperpixel);
|
||||
|
||||
virtual void MakeTexture ();
|
||||
|
|
|
@ -97,13 +97,15 @@ FTexture *FTGATexture::Create(FileReader & file, int lumpnum)
|
|||
}
|
||||
|
||||
|
||||
FTGATexture::FTGATexture (int lumpnum, int w, int h)
|
||||
FTGATexture::FTGATexture (int lumpnum, TGAHeader * hdr)
|
||||
: SourceLump(lumpnum), Pixels(0), Spans(0)
|
||||
{
|
||||
Wads.GetLumpName (Name, lumpnum);
|
||||
Name[8] = 0;
|
||||
Width = w;
|
||||
Height = h;
|
||||
Width = hdr->width;
|
||||
Height = hdr->height;
|
||||
// Alpha channel is used only for 32 bit RGBA and paletted images with RGBA palettes.
|
||||
bMasked = (hdr->img_desc&15)==8 && (hdr->bpp==32 || (hdr->img_type==1 && hdr->cm_size==32));
|
||||
CalcBitSize();
|
||||
}
|
||||
|
||||
|
@ -211,7 +213,6 @@ void FTGATexture::MakeTexture ()
|
|||
hdr.cm_length = LittleShort(hdr.cm_length);
|
||||
#endif
|
||||
|
||||
bMasked = false;
|
||||
if (hdr.has_cm)
|
||||
{
|
||||
memset(PaletteMap, 0, 256);
|
||||
|
@ -236,7 +237,6 @@ void FTGATexture::MakeTexture ()
|
|||
case 32:
|
||||
lump >> b >> g >> r >> a;
|
||||
if ((hdr.img_desc&15)!=8) a=255;
|
||||
else if (a<128) bMasked=true;
|
||||
break;
|
||||
|
||||
default: // should never happen
|
||||
|
@ -333,8 +333,6 @@ void FTGATexture::MakeTexture ()
|
|||
}
|
||||
else
|
||||
{
|
||||
bMasked=true;
|
||||
|
||||
for(int y=0;y<Height;y++)
|
||||
{
|
||||
BYTE * p = ptr + y * Pitch;
|
||||
|
|
Loading…
Reference in a new issue