From 4d2d157ed09bb066686f83803abd90809fe20b82 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 6 Jul 2014 20:53:58 +0000 Subject: Minor cleanups. --- src/model/material.cc | 50 ++++++++++++++++++++++++++------------------------ src/model/material.h | 5 ++--- 2 files changed, 28 insertions(+), 27 deletions(-) (limited to 'src/model') diff --git a/src/model/material.cc b/src/model/material.cc index 25c1f27..29bd80e 100644 --- a/src/model/material.cc +++ b/src/model/material.cc @@ -139,20 +139,22 @@ void Material::set_colortype(ColorType colortype) material_colortype = colortype; } +/* ---- static ----------------------------------------------------- */ + void Material::init() { con_print << "^BInitializing materials..." << std::endl; - filesystem::IFileStream shaderlist("materials/shaderlist.txt"); - if (!shaderlist.is_open()) { - con_warn << "Could not open " << shaderlist.name() << std::endl; + filesystem::IFileStream shaderlistfile("materials/shaderlist.txt"); + if (!shaderlistfile.is_open()) { + con_warn << "Could not open " << shaderlistfile.name() << std::endl; return; } - con_debug << " " << shaderlist.name() << std::endl; + con_debug << " " << shaderlistfile.name() << std::endl; char line[1024]; - while (shaderlist.getline(line, 1023)) { + while (shaderlistfile.getline(line, 1023)) { if ((line[0] == 0) || (line[0] == '#') || (line[0] == ';')) { continue; if ((line[0] == '/') && (line[1] == '/')) @@ -160,11 +162,27 @@ void Material::init() } else { std::string s(line); aux::trim(s); - load_shader(s); + load_shaderfile(s); } } - shaderlist.close(); + shaderlistfile.close(); +} + +void Material::clear() +{ + con_print << "^BClearing materials..." << std::endl; + + for (Registry::iterator i = material_registry.begin(); i != material_registry.end(); ++i) { + delete(*i).second; + } + + material_registry.clear(); +} + +void Material::shutdown() +{ + clear(); } void Material::add(Material *material) @@ -174,7 +192,7 @@ void Material::add(Material *material) } } -void Material::load_shader(const std::string &shadername) +void Material::load_shaderfile(const std::string &shadername) { std::string shaderfilename("materials/"); shaderfilename.append(shadername); @@ -318,22 +336,6 @@ void Material::load_shader(const std::string &shadername) shaderfile.close(); } -void Material::shutdown() -{ - clear(); -} - -void Material::clear() -{ - con_print << "^BClearing materials..." << std::endl; - - for (Registry::iterator i = material_registry.begin(); i != material_registry.end(); ++i) { - delete(*i).second; - } - - material_registry.clear(); -} - void Material::list() { for (Registry::iterator i = material_registry.begin(); i != material_registry.end(); ++i) { diff --git a/src/model/material.h b/src/model/material.h index 94b4418..e2a1276 100644 --- a/src/model/material.h +++ b/src/model/material.h @@ -69,7 +69,7 @@ public: } /** - * @brief returns the material texture size + * @brief returns the material texture pixel size */ inline const math::Vector2f & size() const { return material_size; @@ -153,7 +153,6 @@ public: * */ void set_colortype(ColorType colortype); - /** * @brief set a specified surface flag * @see flags() @@ -221,7 +220,7 @@ private: /// the materials registry static Registry material_registry; - static void load_shader(const std::string &shadername); + static void load_shaderfile(const std::string &shadername); static LoaderFuncPtr material_loaderfunc; }; -- cgit v1.2.3