X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fmaterials%2Ftechnique.cpp;h=26a70a018dde6042ce7ddc5f8b21a2e942257ad5;hp=22f8f3b63a0752ce547863a35eafa455f2e4f3ee;hb=3ac3a51c623271da815c8ee60c484445871753bf;hpb=233dff2a6c552e08da832496aecd88ef4f8948f1 diff --git a/source/materials/technique.cpp b/source/materials/technique.cpp index 22f8f3b6..26a70a01 100644 --- a/source/materials/technique.cpp +++ b/source/materials/technique.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "material.h" #include "program.h" @@ -39,10 +40,10 @@ bool Technique::replace_texture(const string &slot, const Texture &tex) bool replaced = false; for(PassMap::iterator i=passes.begin(); i!=passes.end(); ++i) { - int index = i->second.get_texture_index(slot); - if(index>=0) + Tag tag = i->second.get_texture_tag(slot); + if(tag.id) { - i->second.set_texture(index, &tex); + i->second.set_texture(tag, &tex); replaced = true; } } @@ -69,20 +70,20 @@ bool Technique::replace_material(const string &slot, const Material &mat) bool Technique::replace_uniforms(const ProgramData &shdata) { bool replaced = false; - const vector &uniform_names = shdata.get_uniform_names(); + const vector &uniform_tags = shdata.get_uniform_tags(); for(PassMap::iterator i=passes.begin(); i!=passes.end(); ++i) { RefPtr new_shdata; - for(vector::const_iterator j=uniform_names.begin(); j!=uniform_names.end(); ++j) + for(vector::const_iterator j=uniform_tags.begin(); j!=uniform_tags.end(); ++j) { - const string &name = i->second.get_slotted_uniform_name(*j); - if(name.empty()) + Tag tag = i->second.get_slotted_uniform_tag(*j); + if(!tag.id) continue; if(!new_shdata) new_shdata = new ProgramData(*i->second.get_shader_data()); - new_shdata->uniform(name, shdata.get_uniform(*j)); + new_shdata->uniform(tag, shdata.get_uniform(*j)); replaced = true; } @@ -101,25 +102,42 @@ bool Technique::has_shaders() const return false; } +void Technique::set_debug_name(const std::string &name) +{ +#ifdef DEBUG + for(map::iterator i=passes.begin(); i!=passes.end(); ++i) + i->second.set_debug_name(format("%s [pass:%s]", name, i->first.str())); +#else + (void)name; +#endif +} + + +DataFile::Loader::ActionMap Technique::Loader::shared_actions; Technique::Loader::Loader(Technique &t): DataFile::CollectionObjectLoader(t, 0) { - init(); + set_actions(shared_actions); } Technique::Loader::Loader(Technique &t, Collection &c): DataFile::CollectionObjectLoader(t, &c) { - init(); + set_actions(shared_actions); } -void Technique::Loader::init() +void Technique::Loader::init_actions() { add("inherit", &Loader::inherit); add("pass", &Loader::pass); } +void Technique::Loader::set_inline_base_name(const string &n) +{ + inline_base_name = n; +} + void Technique::Loader::inherit(const string &n) { obj.passes = get_collection().get(n).get_passes(); @@ -131,7 +149,11 @@ void Technique::Loader::pass(const string &n) { RenderPass p; if(coll) - load_sub(p, get_collection()); + { + RenderPass::Loader ldr(p, get_collection()); + ldr.set_inline_base_name(format("%s/%s.pass", (inline_base_name.empty() ? FS::basename(get_source()) : inline_base_name), n)); + load_sub_with(ldr); + } else load_sub(p);