From: Mikko Rasa Date: Wed, 15 Jul 2015 20:03:31 +0000 (+0300) Subject: Expose texture replacement functionality from Technique X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=88a5d6707be2f62e81d46fb6d4781c75742749b8;p=libs%2Fgl.git Expose texture replacement functionality from Technique --- diff --git a/source/technique.cpp b/source/technique.cpp index 15406a93..1e8f8fcc 100644 --- a/source/technique.cpp +++ b/source/technique.cpp @@ -28,6 +28,17 @@ const RenderPass &Technique::get_pass(const GL::Tag &tag) const return get_item(passes, tag); } +void Technique::replace_texture(const string &slot, const Texture &tex) +{ + for(PassMap::iterator i=passes.begin(); i!=passes.end(); ++i) + { + int index = i->second.get_texture_index(slot); + if(index<0) + continue; + i->second.set_texture(index, &tex); + } +} + bool Technique::has_shaders() const { for(PassMap::const_iterator i=passes.begin(); i!=passes.end(); ++i) @@ -97,14 +108,7 @@ void Technique::InheritLoader::material(const string &pass_tag, const string &na void Technique::InheritLoader::texture(const string &slot, const string &name) { - Texture &tex = get_collection().get(name); - for(PassMap::iterator i=obj.passes.begin(); i!=obj.passes.end(); ++i) - { - int index = i->second.get_texture_index(slot); - if(index<0) - continue; - i->second.set_texture(index, &tex); - } + obj.replace_texture(slot, get_collection().get(name)); } } // namespace GL diff --git a/source/technique.h b/source/technique.h index 48e393fc..6841f486 100644 --- a/source/technique.h +++ b/source/technique.h @@ -50,6 +50,7 @@ public: bool has_pass(const GL::Tag &) const; const RenderPass &get_pass(const GL::Tag &) const; const PassMap &get_passes() const { return passes; } + void replace_texture(const std::string &, const Texture &); bool has_shaders() const; };