mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-25 05:21:02 +00:00
- Make BuildTexture inherit from worldtexture.
- handle WorldTextures that can change their content automatically.
This commit is contained in:
parent
94eadb1a8c
commit
47bfbb5e08
2 changed files with 9 additions and 64 deletions
|
@ -48,18 +48,14 @@
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
class FBuildTexture : public FTexture
|
class FBuildTexture : public FWorldTexture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FBuildTexture (int tilenum, const uint8_t *pixels, int width, int height, int left, int top);
|
FBuildTexture (int tilenum, const uint8_t *pixels, int width, int height, int left, int top);
|
||||||
~FBuildTexture ();
|
uint8_t *MakeTexture(FRenderStyle style) override { return const_cast<uint8_t*>(Pixels); } // This is only to make it compile for now and will be changed later.
|
||||||
|
|
||||||
const uint8_t *GetColumn (unsigned int column, const Span **spans_out);
|
|
||||||
const uint8_t *GetPixels ();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const uint8_t *Pixels;
|
const uint8_t *Pixels;
|
||||||
Span **Spans;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,8 +66,9 @@ protected:
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
FBuildTexture::FBuildTexture (int tilenum, const uint8_t *pixels, int width, int height, int left, int top)
|
FBuildTexture::FBuildTexture (int tilenum, const uint8_t *pixels, int width, int height, int left, int top)
|
||||||
: Pixels (pixels), Spans (NULL)
|
: Pixels (pixels)
|
||||||
{
|
{
|
||||||
|
PixelsAreStatic = 3;
|
||||||
Width = width;
|
Width = width;
|
||||||
Height = height;
|
Height = height;
|
||||||
LeftOffset = left;
|
LeftOffset = left;
|
||||||
|
@ -81,62 +78,6 @@ FBuildTexture::FBuildTexture (int tilenum, const uint8_t *pixels, int width, int
|
||||||
UseType = TEX_Build;
|
UseType = TEX_Build;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
FBuildTexture::~FBuildTexture ()
|
|
||||||
{
|
|
||||||
if (Spans != NULL)
|
|
||||||
{
|
|
||||||
FreeSpans (Spans);
|
|
||||||
Spans = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
const uint8_t *FBuildTexture::GetPixels ()
|
|
||||||
{
|
|
||||||
return Pixels;
|
|
||||||
}
|
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
const uint8_t *FBuildTexture::GetColumn (unsigned int column, const Span **spans_out)
|
|
||||||
{
|
|
||||||
if (column >= Width)
|
|
||||||
{
|
|
||||||
if (WidthMask + 1 == Width)
|
|
||||||
{
|
|
||||||
column &= WidthMask;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
column %= Width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (spans_out != NULL)
|
|
||||||
{
|
|
||||||
if (Spans == NULL)
|
|
||||||
{
|
|
||||||
Spans = CreateSpans (Pixels);
|
|
||||||
}
|
|
||||||
*spans_out = Spans[column];
|
|
||||||
}
|
|
||||||
return Pixels + column*Height;
|
|
||||||
}
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// AddTiles
|
// AddTiles
|
||||||
|
|
|
@ -124,6 +124,10 @@ const uint8_t *FWorldTexture::GetColumn (unsigned int column, const Span **spans
|
||||||
|
|
||||||
const uint8_t *FWorldTexture::GetPixels ()
|
const uint8_t *FWorldTexture::GetPixels ()
|
||||||
{
|
{
|
||||||
|
if (CheckModified())
|
||||||
|
{
|
||||||
|
Unload();
|
||||||
|
}
|
||||||
if (Pixeldata[0] == nullptr)
|
if (Pixeldata[0] == nullptr)
|
||||||
{
|
{
|
||||||
Pixeldata[0] = MakeTexture (LegacyRenderStyles[STYLE_Normal]);
|
Pixeldata[0] = MakeTexture (LegacyRenderStyles[STYLE_Normal]);
|
||||||
|
|
Loading…
Reference in a new issue