mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 22:33:17 +00:00
Use FImageTexture for thre null texture
FDummyTexture had a big problem: Whenever it was accessed by accident it crashed the app because it wasn't fully implemented. What it should do is return empty pixels of the given size, and an unextended FImageTexture is doing just that.
This commit is contained in:
parent
b32aa60760
commit
0d07fb2550
4 changed files with 13 additions and 31 deletions
|
@ -364,7 +364,7 @@ void FMultipatchTextureBuilder::AddTexturesLump(const void *lumpdata, int lumpsi
|
|||
// It still needs to be created in case someone uses it by name.
|
||||
offset = LittleLong(directory[1]);
|
||||
const maptexture_t *tex = (const maptexture_t *)((const uint8_t *)maptex + offset);
|
||||
FDummyTexture *tex0 = static_cast<FDummyTexture *>(TexMan.ByIndex(0));
|
||||
FTexture *tex0 = TexMan.ByIndex(0);
|
||||
tex0->SetSize(SAFESHORT(tex->width), SAFESHORT(tex->height));
|
||||
}
|
||||
|
||||
|
|
|
@ -761,26 +761,6 @@ TArray<uint8_t> FTexture::Get8BitPixels(bool alphatex)
|
|||
return Pixels;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Dummy texture for the 0-entry.
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
FDummyTexture::FDummyTexture ()
|
||||
{
|
||||
Width = 64;
|
||||
Height = 64;
|
||||
UseType = ETextureType::Null;
|
||||
}
|
||||
|
||||
void FDummyTexture::SetSize (int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
|
|
@ -1003,7 +1003,9 @@ void FTextureManager::Init()
|
|||
FTexture::InitGrayMap();
|
||||
|
||||
// Texture 0 is a dummy texture used to indicate "no texture"
|
||||
AddTexture (new FDummyTexture);
|
||||
auto nulltex = new FImageTexture(nullptr);
|
||||
nulltex->SetUseType(ETextureType::Null);
|
||||
AddTexture (nulltex);
|
||||
// some special textures used in the game.
|
||||
AddTexture(CreateShaderTexture(false, false));
|
||||
AddTexture(CreateShaderTexture(false, true));
|
||||
|
|
|
@ -382,7 +382,15 @@ protected:
|
|||
float shaderspeed = 1.f;
|
||||
int shaderindex = 0;
|
||||
|
||||
|
||||
// This is only legal for the null texture!
|
||||
void SetSize(int w, int h)
|
||||
{
|
||||
if (UseType == ETextureType::Null)
|
||||
{
|
||||
Width = w;
|
||||
Height = h;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns true if GetPixelsBgra includes mipmaps
|
||||
virtual bool Mipmapped() { return true; }
|
||||
|
@ -657,14 +665,6 @@ public:
|
|||
|
||||
};
|
||||
|
||||
// A texture that doesn't really exist
|
||||
class FDummyTexture : public FTexture
|
||||
{
|
||||
public:
|
||||
FDummyTexture ();
|
||||
void SetSize (int width, int height);
|
||||
};
|
||||
|
||||
|
||||
// A texture that can be drawn to.
|
||||
class DCanvas;
|
||||
|
|
Loading…
Reference in a new issue