diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 7dde2b25a..dea96015b 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -289,7 +289,7 @@ void CGraphics_Threaded::FreeTextureIndex(CTextureHandle *pIndex) int CGraphics_Threaded::UnloadTexture(CTextureHandle *pIndex) { - if(pIndex->Id() == m_InvalidTexture.Id()) + if(pIndex->Id() == m_NullTexture.Id()) return 0; if(!pIndex->IsValid()) @@ -492,12 +492,12 @@ IGraphics::CTextureHandle CGraphics_Threaded::LoadTexture(const char *pFilename, } } - return m_InvalidTexture; + return m_NullTexture; } -IGraphics::CTextureHandle CGraphics_Threaded::InvalidTexture() const +IGraphics::CTextureHandle CGraphics_Threaded::NullTexture() const { - return m_InvalidTexture; + return m_NullTexture; } bool CGraphics_Threaded::LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, void *pTextData, void *pTextOutlineData) @@ -2612,27 +2612,28 @@ int CGraphics_Threaded::Init() const unsigned char aGreen[] = {0x00, 0xff, 0x00, 0xff}; const unsigned char aBlue[] = {0x00, 0x00, 0xff, 0xff}; const unsigned char aYellow[] = {0xff, 0xff, 0x00, 0xff}; - constexpr size_t InvalidTextureDimension = 16; - unsigned char aNullTextureData[InvalidTextureDimension * InvalidTextureDimension * PixelSize]; - for(size_t y = 0; y < InvalidTextureDimension; ++y) + constexpr size_t NullTextureDimension = 16; + unsigned char aNullTextureData[NullTextureDimension * NullTextureDimension * PixelSize]; + for(size_t y = 0; y < NullTextureDimension; ++y) { - for(size_t x = 0; x < InvalidTextureDimension; ++x) + for(size_t x = 0; x < NullTextureDimension; ++x) { const unsigned char *pColor; - if(x < InvalidTextureDimension / 2 && y < InvalidTextureDimension / 2) + if(x < NullTextureDimension / 2 && y < NullTextureDimension / 2) pColor = aRed; - else if(x >= InvalidTextureDimension / 2 && y < InvalidTextureDimension / 2) + else if(x >= NullTextureDimension / 2 && y < NullTextureDimension / 2) pColor = aGreen; - else if(x < InvalidTextureDimension / 2 && y >= InvalidTextureDimension / 2) + else if(x < NullTextureDimension / 2 && y >= NullTextureDimension / 2) pColor = aBlue; else pColor = aYellow; - mem_copy(&aNullTextureData[(y * InvalidTextureDimension + x) * PixelSize], pColor, PixelSize); + mem_copy(&aNullTextureData[(y * NullTextureDimension + x) * PixelSize], pColor, PixelSize); } } const int TextureLoadFlags = HasTextureArrays() ? IGraphics::TEXLOAD_TO_2D_ARRAY_TEXTURE : IGraphics::TEXLOAD_TO_3D_TEXTURE; - m_InvalidTexture.Invalidate(); - m_InvalidTexture = LoadTextureRaw(InvalidTextureDimension, InvalidTextureDimension, CImageInfo::FORMAT_RGBA, aNullTextureData, TextureLoadFlags); + m_NullTexture.Invalidate(); + m_NullTexture = LoadTextureRaw(NullTextureDimension, NullTextureDimension, CImageInfo::FORMAT_RGBA, aNullTextureData, TextureLoadFlags); + dbg_assert(m_NullTexture.IsNullTexture(), "Null texture invalid"); } ColorRGBA GPUInfoPrintColor{0.6f, 0.5f, 1.0f, 1.0f}; diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 9dcf339ea..f7ff189fb 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -816,7 +816,7 @@ class CGraphics_Threaded : public IEngineGraphics bool m_DoScreenshot; char m_aScreenshotName[IO_MAX_PATH_LENGTH]; - CTextureHandle m_InvalidTexture; + CTextureHandle m_NullTexture; std::vector m_vTextureIndices; size_t m_FirstFreeTexture; @@ -968,7 +968,7 @@ public: int UnloadTexture(IGraphics::CTextureHandle *pIndex) override; IGraphics::CTextureHandle LoadTextureRaw(size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData, int Flags, const char *pTexName = nullptr) override; int LoadTextureRawSub(IGraphics::CTextureHandle TextureID, int x, int y, size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData) override; - IGraphics::CTextureHandle InvalidTexture() const override; + IGraphics::CTextureHandle NullTexture() const override; bool LoadTextTextures(size_t Width, size_t Height, CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture, void *pTextData, void *pTextOutlineData) override; bool UnloadTextTextures(CTextureHandle &TextTexture, CTextureHandle &TextOutlineTexture) override; diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 0d164ae5f..24b2b3dfd 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -263,6 +263,7 @@ public: } bool IsValid() const { return Id() >= 0; } + bool IsNullTexture() const { return Id() == 0; } int Id() const { return m_Id; } void Invalidate() { m_Id = -1; } }; @@ -337,7 +338,7 @@ public: virtual CTextureHandle LoadTextureRaw(size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData, int Flags, const char *pTexName = nullptr) = 0; virtual int LoadTextureRawSub(CTextureHandle TextureID, int x, int y, size_t Width, size_t Height, CImageInfo::EImageFormat Format, const void *pData) = 0; virtual CTextureHandle LoadTexture(const char *pFilename, int StorageType, int Flags = 0) = 0; - virtual CTextureHandle InvalidTexture() const = 0; + virtual CTextureHandle NullTexture() const = 0; virtual void TextureSet(CTextureHandle Texture) = 0; void TextureClear() { TextureSet(CTextureHandle()); } diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp index 54a5bb9a3..434bbfe0f 100644 --- a/src/game/client/components/mapimages.cpp +++ b/src/game/client/components/mapimages.cpp @@ -138,7 +138,7 @@ void CMapImages::OnMapLoadImpl(class CLayers *pLayers, IMap *pMap) pMap->UnloadData(pImg->m_ImageData); } pMap->UnloadData(pImg->m_ImageName); - ShowWarning = ShowWarning || m_aTextures[i].Id() == Graphics()->InvalidTexture().Id(); + ShowWarning = ShowWarning || m_aTextures[i].IsNullTexture(); } if(ShowWarning) {