X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterials%2Fmaterial.cpp;h=b2ee973ad11c0b8d55fc4d6ea14dabaebf31a3a8;hb=fe2fc291a4fc618425c64112c9ffd3519f0b8a3e;hp=b737c03183b504b82592f5959cfd70e80ec10f77;hpb=cb7db94f7837e6a3be037d07575dc248177d9426;p=libs%2Fgl.git diff --git a/source/materials/material.cpp b/source/materials/material.cpp index b737c031..b2ee973a 100644 --- a/source/materials/material.cpp +++ b/source/materials/material.cpp @@ -13,7 +13,7 @@ using namespace std; namespace Msp { namespace GL { -const Program *Material::create_compatible_shader(DataFile::Collection &coll, const map &extra_spec) const +const Program *Material::create_compatible_shader(const map &extra_spec) const { string module_name; map spec_values; @@ -26,16 +26,17 @@ const Program *Material::create_compatible_shader(DataFile::Collection &coll, co for(map::const_iterator i=spec_values.begin(); i!=spec_values.end(); ++i) info += format(",%s:%d", i->first, i->second); + Resources &res = Resources::get_global(); string name = format("_material_%016x.shader", hash64(info)); - Program *shprog = coll.find(name); + Program *shprog = res.find(name); if(shprog) return shprog; - const Module &module = coll.get(module_name); + const Module &module = res.get(module_name); shprog = new Program(module, spec_values); try { - coll.add(name, shprog); + res.add(name, shprog); } catch(...) { @@ -69,6 +70,15 @@ void Material::attach_texture_to(const Texture *tex, Texturing &texturing, Progr } #pragma GCC diagnostic pop +void Material::set_debug_name(const string &name) +{ +#ifdef DEBUG + shdata.set_debug_name(name+" [UBO]"); +#else + (void)name; +#endif +} + Material::MaterialRegistry &Material::get_material_registry() { static MaterialRegistry registry;