From 88a5d6707be2f62e81d46fb6d4781c75742749b8 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 15 Jul 2015 23:03:31 +0300 Subject: [PATCH] Expose texture replacement functionality from Technique --- source/technique.cpp | 20 ++++++++++++-------- source/technique.h | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) 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; }; -- 2.43.0