Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/material.cc')
-rw-r--r--src/model/material.cc35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/model/material.cc b/src/model/material.cc
index 9f47f1e..93492f5 100644
--- a/src/model/material.cc
+++ b/src/model/material.cc
@@ -240,8 +240,7 @@ void Material::load_shaderfile(const std::string &shadername)
material = 0;
layer = 0;
} else {
- material = new Material(firstword);
- material_registry[material->name()] = material;
+ material = add(firstword);
count++;
layer = 0;
@@ -386,20 +385,33 @@ void Material::load_shaderfile(const std::string &shadername)
void Material::list()
{
- for (Registry::iterator i = material_registry.begin(); i != material_registry.end(); ++i) {
+ for (Registry::iterator i = material_registry.begin(); i != material_registry.end(); ++i)
+ {
con_print << " " << (*i).second->name() << std::endl;
}
con_print << material_registry.size() << " registered materials" << std::endl;
}
+
+Material * Material::add(const std::string &name)
+{
+ Material *material = new Material(name);
+ material_registry[material->name()] = material;
+
+ return material;
+}
+
Material *Material::find(const std::string &name)
{
std::string searchstr(name);
aux::to_lowercase(searchstr);
- for (Registry::iterator i = material_registry.begin(); i != material_registry.end(); ++i) {
+ for (Registry::iterator i = material_registry.begin(); i != material_registry.end(); ++i)
+ {
if ((*i).first.compare(searchstr) == 0)
+ {
return (*i).second;
+ }
}
return 0;
}
@@ -414,27 +426,26 @@ Material *Material::load(const std::string &name, const bool ui_texture)
}
// create a new material
- material = new Material(name);
+ material = add(name);
- // create a single layer
- Layer *layer = new Layer();
+ // add a single layer
+ Layer *layer = material->add_layer();
// add a texture
layer->set_texture(name);
- if (ui_texture) {
+ if (ui_texture)
+ {
layer->set_fullbright(true);
layer->set_blendfunc(Layer::BlendFuncBlend);
}
if (material_imageloaderfunc) {
material_imageloaderfunc(layer);
- if ((layer->size().width() > 0) && (layer->size().height() > 0)) {
+ if ((layer->size().width() > 0) && (layer->size().height() > 0))
+ {
material->material_size.assign(layer->size());
}
}
- // add the new layer to the material
- material->material_layers.push_back(layer);
-
// add the new material to the registry
material_registry[material->name()] = material;