1 #include <msp/core/refptr.h>
2 #include <msp/datafile/collection.h>
3 #include <msp/strings/format.h>
6 #include "programdata.h"
16 RenderPass &Technique::add_pass(const GL::Tag &tag)
18 return insert_unique(passes, tag, RenderPass())->second;
21 bool Technique::has_pass(const GL::Tag &tag) const
23 return passes.count(tag);
26 const RenderPass &Technique::get_pass(const GL::Tag &tag) const
28 return get_item(passes, tag);
31 bool Technique::has_shaders() const
33 for(PassMap::const_iterator i=passes.begin(); i!=passes.end(); ++i)
34 if(i->second.get_shader_program())
40 Technique::Loader::Loader(Technique &t):
41 DataFile::CollectionObjectLoader<Technique>(t, 0)
46 Technique::Loader::Loader(Technique &t, Collection &c):
47 DataFile::CollectionObjectLoader<Technique>(t, &c)
52 void Technique::Loader::init()
54 add("inherit", &Loader::inherit);
55 add("pass", &Loader::pass);
58 void Technique::Loader::inherit(const string &n)
60 obj.passes = get_collection().get<Technique>(n).get_passes();
61 InheritLoader ldr(obj, get_collection());
65 void Technique::Loader::pass(const string &n)
69 load_sub(p, get_collection());
73 insert_unique(obj.passes, n, p);
77 Technique::InheritLoader::InheritLoader(Technique &t, Collection &c):
78 DataFile::CollectionObjectLoader<Technique>(t, &c)
80 add("texture", &InheritLoader::texture);
83 void Technique::InheritLoader::texture(const std::string &slot, const string &name)
85 Texture &tex = get_collection().get<Texture>(name);
86 for(PassMap::iterator i=obj.passes.begin(); i!=obj.passes.end(); ++i)
88 int index = i->second.get_texture_index(slot);
91 i->second.set_texture(index, &tex);