Commit 71c42fb1 authored by hybrid's avatar hybrid

Make the material name string array local to SMaterial, public, and up to date.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@790 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 95505b00
...@@ -190,6 +190,37 @@ namespace video ...@@ -190,6 +190,37 @@ namespace video
EMT_FORCE_32BIT = 0x7fffffff EMT_FORCE_32BIT = 0x7fffffff
}; };
//! Array holding the built in material type names
const char* const sBuiltInMaterialTypeNames[] =
{
"solid",
"solid_2layer",
"lightmap",
"lightmap_add",
"lightmap_m2",
"lightmap_m4",
"lightmap_light",
"lightmap_light_m2",
"lightmap_light_m4",
"detail_map",
"sphere_map",
"reflection_2layer",
"trans_add",
"trans_alphach",
"trans_alphach_ref",
"trans_vertex_alpha",
"trans_reflection_2layer",
"normalmap_solid",
"normalmap_trans_add",
"normalmap_trans_vertexalpha",
"parallaxmap_solid",
"parallaxmap_trans_add",
"parallaxmap_trans_vertexalpha",
"onetexture_blend",
0
};
//! Flag for EMT_ONETEXTURE_BLEND, ( BlendFactor ) //! Flag for EMT_ONETEXTURE_BLEND, ( BlendFactor )
//! BlendFunc = source * sourceFactor + dest * destFactor //! BlendFunc = source * sourceFactor + dest * destFactor
enum E_BLEND_FACTOR enum E_BLEND_FACTOR
......
...@@ -60,35 +60,6 @@ IImageWriter* createImageWriterPPM(); ...@@ -60,35 +60,6 @@ IImageWriter* createImageWriterPPM();
//! Array holding the built in material type names
const char* const sBuiltInMaterialTypeNames[] =
{
"solid",
"solid_2layer",
"lightmap",
"lightmap_add",
"lightmap_m2",
"lightmap_m4",
"lightmap_light",
"lightmap_light_m2",
"lightmap_light_m4",
"detail_map",
"sphere_map",
"reflection_2layer",
"trans_add",
"trans_alphach",
"trans_alphach_ref",
"trans_vertex_alpha",
"trans_reflection_2layer",
"normalmap_solid",
"normalmap_trans_add",
"normalmap_trans_vertexalpha",
"parallaxmap_solid",
"parallaxmap_trans_add",
"parallaxmap_trans_vertexalpha"
};
//! constructor //! constructor
CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<s32>& screenSize) CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d<s32>& screenSize)
: FileSystem(io), ViewPort(0,0,0,0), ScreenSize(screenSize), : FileSystem(io), ViewPort(0,0,0,0), ScreenSize(screenSize),
...@@ -1271,10 +1242,10 @@ s32 CNullDriver::addMaterialRenderer(IMaterialRenderer* renderer, const char* na ...@@ -1271,10 +1242,10 @@ s32 CNullDriver::addMaterialRenderer(IMaterialRenderer* renderer, const char* na
r.Renderer = renderer; r.Renderer = renderer;
r.Name = name; r.Name = name;
if (name == 0 && (MaterialRenderers.size() < sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))) if (name == 0 && (MaterialRenderers.size() < (sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))-1 ))
{ {
// set name of built in renderer so that we don't have to implement name // set name of built in renderer so that we don't have to implement name
// setting in all 5 available renderers. // setting in all available renderers.
r.Name = sBuiltInMaterialTypeNames[MaterialRenderers.size()]; r.Name = sBuiltInMaterialTypeNames[MaterialRenderers.size()];
} }
...@@ -1288,7 +1259,7 @@ s32 CNullDriver::addMaterialRenderer(IMaterialRenderer* renderer, const char* na ...@@ -1288,7 +1259,7 @@ s32 CNullDriver::addMaterialRenderer(IMaterialRenderer* renderer, const char* na
//! Sets the name of a material renderer. //! Sets the name of a material renderer.
void CNullDriver::setMaterialRendererName(s32 idx, const char* name) void CNullDriver::setMaterialRendererName(s32 idx, const char* name)
{ {
if (idx < s32(sizeof(sBuiltInMaterialTypeNames) / sizeof(char*)) || if (idx < s32(sizeof(sBuiltInMaterialTypeNames) / sizeof(char*))-1 ||
idx >= (s32)MaterialRenderers.size()) idx >= (s32)MaterialRenderers.size())
return; return;
...@@ -1301,16 +1272,7 @@ io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMateria ...@@ -1301,16 +1272,7 @@ io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMateria
{ {
io::CAttributes* attr = new io::CAttributes(this); io::CAttributes* attr = new io::CAttributes(this);
const char** materialNames = new const char*[MaterialRenderers.size()+1]; attr->addEnum("Type", material.MaterialType, sBuiltInMaterialTypeNames);
u32 i;
for (i=0; i < MaterialRenderers.size(); ++i)
materialNames[i] = MaterialRenderers[i].Name.c_str();
materialNames[MaterialRenderers.size()] = 0;
attr->addEnum("Type", material.MaterialType, materialNames);
delete [] materialNames;
attr->addColor("Ambient", material.AmbientColor); attr->addColor("Ambient", material.AmbientColor);
attr->addColor("Diffuse", material.DiffuseColor); attr->addColor("Diffuse", material.DiffuseColor);
...@@ -1322,6 +1284,7 @@ io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMateria ...@@ -1322,6 +1284,7 @@ io::IAttributes* CNullDriver::createAttributesFromMaterial(const video::SMateria
attr->addFloat("Param2", material.MaterialTypeParam2); attr->addFloat("Param2", material.MaterialTypeParam2);
core::stringc prefix="Texture"; core::stringc prefix="Texture";
u32 i;
for (i=0; i<MATERIAL_MAX_TEXTURES; ++i) for (i=0; i<MATERIAL_MAX_TEXTURES; ++i)
attr->addTexture((prefix+(i+1)).c_str(), material.Textures[i]); attr->addTexture((prefix+(i+1)).c_str(), material.Textures[i]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment