- split out the span generation from most texture classes

Until now each subclass of FTexture had to implement the entire span generation itself, presumably so that a few classes can use simpler structures.
This does not work if a texture can have more than one pixel buffer as is needed for alpha textures.
Even though it means that some classes will allocate more data now, it's the only way to do it properly.
In addition this removes a significant amount of mostly redundant code from the texture classes.

- added alpha texture processing to all converted classes

As of now this is not active and not tested.
Note that as part of the conversion even those textures that were working as alphatextures will not look correct until the higher level code gets adjusted.
This commit is contained in:
Christoph Oelckers 2018-03-18 12:36:14 +01:00
commit 7e169eb76f
21 changed files with 484 additions and 1416 deletions

View file

@ -1,7 +1,8 @@
/*
** flattexture.cpp
** emptytexture.cpp
** Texture class for empty placeholder textures
** (essentially patches with dimensions and offsets of (0,0) )
** These need special treatment because a texture size of 0 is illegal
**
**---------------------------------------------------------------------------
** Copyright 2009 Christoph Oelckers
@ -41,30 +42,21 @@
//==========================================================================
//
// A texture defined between F_START and F_END markers
//
//
//==========================================================================
class FEmptyTexture : public FTexture
class FEmptyTexture : public FWorldTexture
{
uint8_t Pixel = 0;
public:
FEmptyTexture (int lumpnum);
const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
const uint8_t *GetPixels ();
void Unload() {}
protected:
uint8_t Pixels[1];
Span DummySpans[1];
uint8_t *MakeTexture(FRenderStyle style) override;
};
//==========================================================================
//
// Since there is no way to detect the validity of a flat
// they can't be used anywhere else but between F_START and F_END
//
//
//==========================================================================
@ -86,15 +78,13 @@ FTexture *EmptyTexture_TryCreate(FileReader & file, int lumpnum)
//==========================================================================
FEmptyTexture::FEmptyTexture (int lumpnum)
: FTexture(NULL, lumpnum)
: FWorldTexture(NULL, lumpnum)
{
bMasked = true;
WidthBits = HeightBits = 1;
Width = Height = 1;
WidthMask = 0;
DummySpans[0].TopOffset = 0;
DummySpans[0].Length = 0;
Pixels[0] = 0;
PixelsAreStatic = 3;
}
//==========================================================================
@ -103,23 +93,8 @@ FEmptyTexture::FEmptyTexture (int lumpnum)
//
//==========================================================================
const uint8_t *FEmptyTexture::GetColumn (unsigned int column, const Span **spans_out)
uint8_t *FEmptyTexture::MakeTexture(FRenderStyle style)
{
if (spans_out != NULL)
{
*spans_out = DummySpans;
}
return Pixels;
}
//==========================================================================
//
//
//
//==========================================================================
const uint8_t *FEmptyTexture::GetPixels ()
{
return Pixels;
return &Pixel;
}