1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-11-17 07:05:29 +01:00

Introduce EMT_INVALID as safe placeholder

This commit is contained in:
sfan5
2025-11-07 13:30:26 +01:00
parent fad3a0fa6d
commit c3790dd7af
8 changed files with 16 additions and 23 deletions

View File

@@ -38,16 +38,6 @@ IImageWriter *createImageWriterJPG();
//! creates a writer which is able to save png images
IImageWriter *createImageWriterPNG();
namespace
{
//! no-op material renderer
class CDummyMaterialRenderer : public IMaterialRenderer
{
public:
CDummyMaterialRenderer() {}
};
}
//! constructor
CNullDriver::CNullDriver(io::IFileSystem *io, const core::dimension2d<u32> &screenSize) :
SharedRenderTarget(0), CurrentRenderTarget(0), CurrentRenderTargetSize(0, 0), FileSystem(io), MeshManipulator(0),
@@ -1505,7 +1495,7 @@ void CNullDriver::deleteShaderMaterial(s32 material)
auto &ref = MaterialRenderers[idx];
if (ref.Renderer)
ref.Renderer->drop();
ref.Renderer = new CDummyMaterialRenderer();
ref.Renderer = new IMaterialRenderer();
ref.Name.clear();
}

View File

@@ -1700,6 +1700,8 @@ void COpenGLDriver::setRenderStates3DMode()
if (static_cast<u32>(Material.MaterialType) < MaterialRenderers.size())
MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial(
Material, LastMaterial, ResetRenderStates, this);
else
os::Printer::log("Attempt to render with invalid material", ELL_WARNING);
LastMaterial = Material;
CacheHandler->correctCacheMaterial(LastMaterial);

View File

@@ -1176,6 +1176,8 @@ void COpenGL3DriverBase::setRenderStates3DMode()
if (static_cast<u32>(Material.MaterialType) < MaterialRenderers.size())
MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial(
Material, LastMaterial, ResetRenderStates, this);
else
os::Printer::log("Attempt to render with invalid material", ELL_WARNING);
LastMaterial = Material;
CacheHandler->correctCacheMaterial(LastMaterial);