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);
32 Technique::Loader::Loader(Technique &t):
33 DataFile::CollectionObjectLoader<Technique>(t, 0)
38 Technique::Loader::Loader(Technique &t, Collection &c):
39 DataFile::CollectionObjectLoader<Technique>(t, &c)
44 void Technique::Loader::init()
46 add("inherit", &Loader::inherit);
47 add("pass", &Loader::pass);
50 void Technique::Loader::inherit(const string &n)
52 obj.passes = get_collection().get<Technique>(n).get_passes();
53 InheritLoader ldr(obj, get_collection());
57 void Technique::Loader::pass(const string &n)
61 load_sub(p, get_collection());
65 insert_unique(obj.passes, n, p);
69 Technique::InheritLoader::InheritLoader(Technique &t, Collection &c):
70 DataFile::CollectionObjectLoader<Technique>(t, &c)
72 add("texture", &InheritLoader::texture);
75 void Technique::InheritLoader::texture(const std::string &slot, const string &name)
77 Texture &tex = get_collection().get<Texture>(name);
78 for(PassMap::iterator i=obj.passes.begin(); i!=obj.passes.end(); ++i)
80 int index = i->second.get_texture_index(slot);
83 i->second.set_texture(index, &tex);