mirror of
https://github.com/luanti-org/luanti.git
synced 2025-11-17 15:15:27 +01:00
Introduce EMT_INVALID as safe placeholder
This commit is contained in:
@@ -10,7 +10,7 @@ namespace video
|
|||||||
{
|
{
|
||||||
|
|
||||||
//! Abstracted and easy to use fixed function/programmable pipeline material modes.
|
//! Abstracted and easy to use fixed function/programmable pipeline material modes.
|
||||||
enum E_MATERIAL_TYPE
|
enum E_MATERIAL_TYPE : u32
|
||||||
{
|
{
|
||||||
//! Standard solid material.
|
//! Standard solid material.
|
||||||
/** Only first texture is used, which is supposed to be the
|
/** Only first texture is used, which is supposed to be the
|
||||||
@@ -51,15 +51,15 @@ enum E_MATERIAL_TYPE
|
|||||||
pack_textureBlendFunc (for 2D) or pack_textureBlendFuncSeparate (for 3D). */
|
pack_textureBlendFunc (for 2D) or pack_textureBlendFuncSeparate (for 3D). */
|
||||||
EMT_ONETEXTURE_BLEND,
|
EMT_ONETEXTURE_BLEND,
|
||||||
|
|
||||||
//! This value is not used. It only forces this enumeration to compile to 32 bit.
|
//! Invalid value
|
||||||
EMT_FORCE_32BIT = 0x7fffffff
|
EMT_INVALID = 0xffffffff,
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Array holding the built in material type names
|
//! Array holding the built in material type names
|
||||||
const char *const sBuiltInMaterialTypeNames[] = {
|
const char *const sBuiltInMaterialTypeNames[] = {
|
||||||
"solid",
|
"solid",
|
||||||
"trans_alphach",
|
"trans_alpha",
|
||||||
"trans_alphach_ref",
|
"trans_alpha_ref",
|
||||||
"trans_vertex_alpha",
|
"trans_vertex_alpha",
|
||||||
"onetexture_blend",
|
"onetexture_blend",
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -38,16 +38,6 @@ IImageWriter *createImageWriterJPG();
|
|||||||
//! creates a writer which is able to save png images
|
//! creates a writer which is able to save png images
|
||||||
IImageWriter *createImageWriterPNG();
|
IImageWriter *createImageWriterPNG();
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
//! no-op material renderer
|
|
||||||
class CDummyMaterialRenderer : public IMaterialRenderer
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CDummyMaterialRenderer() {}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
CNullDriver::CNullDriver(io::IFileSystem *io, const core::dimension2d<u32> &screenSize) :
|
CNullDriver::CNullDriver(io::IFileSystem *io, const core::dimension2d<u32> &screenSize) :
|
||||||
SharedRenderTarget(0), CurrentRenderTarget(0), CurrentRenderTargetSize(0, 0), FileSystem(io), MeshManipulator(0),
|
SharedRenderTarget(0), CurrentRenderTarget(0), CurrentRenderTargetSize(0, 0), FileSystem(io), MeshManipulator(0),
|
||||||
@@ -1505,7 +1495,7 @@ void CNullDriver::deleteShaderMaterial(s32 material)
|
|||||||
auto &ref = MaterialRenderers[idx];
|
auto &ref = MaterialRenderers[idx];
|
||||||
if (ref.Renderer)
|
if (ref.Renderer)
|
||||||
ref.Renderer->drop();
|
ref.Renderer->drop();
|
||||||
ref.Renderer = new CDummyMaterialRenderer();
|
ref.Renderer = new IMaterialRenderer();
|
||||||
ref.Name.clear();
|
ref.Name.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1700,6 +1700,8 @@ void COpenGLDriver::setRenderStates3DMode()
|
|||||||
if (static_cast<u32>(Material.MaterialType) < MaterialRenderers.size())
|
if (static_cast<u32>(Material.MaterialType) < MaterialRenderers.size())
|
||||||
MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial(
|
MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial(
|
||||||
Material, LastMaterial, ResetRenderStates, this);
|
Material, LastMaterial, ResetRenderStates, this);
|
||||||
|
else
|
||||||
|
os::Printer::log("Attempt to render with invalid material", ELL_WARNING);
|
||||||
|
|
||||||
LastMaterial = Material;
|
LastMaterial = Material;
|
||||||
CacheHandler->correctCacheMaterial(LastMaterial);
|
CacheHandler->correctCacheMaterial(LastMaterial);
|
||||||
|
|||||||
@@ -1176,6 +1176,8 @@ void COpenGL3DriverBase::setRenderStates3DMode()
|
|||||||
if (static_cast<u32>(Material.MaterialType) < MaterialRenderers.size())
|
if (static_cast<u32>(Material.MaterialType) < MaterialRenderers.size())
|
||||||
MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial(
|
MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial(
|
||||||
Material, LastMaterial, ResetRenderStates, this);
|
Material, LastMaterial, ResetRenderStates, this);
|
||||||
|
else
|
||||||
|
os::Printer::log("Attempt to render with invalid material", ELL_WARNING);
|
||||||
|
|
||||||
LastMaterial = Material;
|
LastMaterial = Material;
|
||||||
CacheHandler->correctCacheMaterial(LastMaterial);
|
CacheHandler->correctCacheMaterial(LastMaterial);
|
||||||
|
|||||||
@@ -599,14 +599,14 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
|
|||||||
m_material_type = shader_source->getShaderInfo(shader_id).material;
|
m_material_type = shader_source->getShaderInfo(shader_id).material;
|
||||||
} else {
|
} else {
|
||||||
// Not used, so make sure it's not valid
|
// Not used, so make sure it's not valid
|
||||||
m_material_type = EMT_INVALID;
|
m_material_type = video::EMT_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_matrixnode = m_smgr->addDummyTransformationSceneNode();
|
m_matrixnode = m_smgr->addDummyTransformationSceneNode();
|
||||||
m_matrixnode->grab();
|
m_matrixnode->grab();
|
||||||
|
|
||||||
auto setMaterial = [this] (video::SMaterial &mat) {
|
auto setMaterial = [this] (video::SMaterial &mat) {
|
||||||
if (m_material_type != EMT_INVALID)
|
if (m_material_type != video::EMT_INVALID)
|
||||||
mat.MaterialType = m_material_type;
|
mat.MaterialType = m_material_type;
|
||||||
mat.FogEnable = true;
|
mat.FogEnable = true;
|
||||||
mat.forEachTexture([] (auto &tex) {
|
mat.forEachTexture([] (auto &tex) {
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ struct MeshAnimationInfo {
|
|||||||
class GenericCAO : public ClientActiveObject
|
class GenericCAO : public ClientActiveObject
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static constexpr auto EMT_INVALID = video::EMT_FORCE_32BIT;
|
|
||||||
|
|
||||||
// Only set at initialization
|
// Only set at initialization
|
||||||
std::string m_name = "";
|
std::string m_name = "";
|
||||||
@@ -101,7 +100,7 @@ private:
|
|||||||
std::vector<MeshAnimationInfo> m_meshnode_animation;
|
std::vector<MeshAnimationInfo> m_meshnode_animation;
|
||||||
|
|
||||||
// Material
|
// Material
|
||||||
video::E_MATERIAL_TYPE m_material_type = EMT_INVALID;
|
video::E_MATERIAL_TYPE m_material_type = video::EMT_INVALID;
|
||||||
|
|
||||||
// Movement
|
// Movement
|
||||||
v3f m_position = v3f(0.0f, 10.0f * BS, 0);
|
v3f m_position = v3f(0.0f, 10.0f * BS, 0);
|
||||||
|
|||||||
@@ -640,7 +640,7 @@ void ShaderSource::rebuildShaders()
|
|||||||
for (ShaderInfo &i : m_shaderinfo_cache) {
|
for (ShaderInfo &i : m_shaderinfo_cache) {
|
||||||
if (!i.name.empty()) {
|
if (!i.name.empty()) {
|
||||||
gpu->deleteShaderMaterial(i.material);
|
gpu->deleteShaderMaterial(i.material);
|
||||||
i.material = video::EMT_SOLID; // invalidate
|
i.material = video::EMT_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,9 +229,9 @@ using CachedStructPixelShaderSetting = CachedStructShaderSetting<T, count, cache
|
|||||||
|
|
||||||
struct ShaderInfo {
|
struct ShaderInfo {
|
||||||
std::string name;
|
std::string name;
|
||||||
video::E_MATERIAL_TYPE base_material = video::EMT_SOLID;
|
video::E_MATERIAL_TYPE base_material = video::EMT_INVALID;
|
||||||
// Material ID the shader has received from Irrlicht
|
// Material ID the shader has received from Irrlicht
|
||||||
video::E_MATERIAL_TYPE material = video::EMT_SOLID;
|
video::E_MATERIAL_TYPE material = video::EMT_INVALID;
|
||||||
// Input constants
|
// Input constants
|
||||||
ShaderConstants input_constants;
|
ShaderConstants input_constants;
|
||||||
// Extra uniform callback
|
// Extra uniform callback
|
||||||
|
|||||||
Reference in New Issue
Block a user