]> git.tdb.fi Git - libs/gl.git/blob - source/materials/technique.h
Convert Technique and RenderPass loaders to use shared actions
[libs/gl.git] / source / materials / technique.h
1 #ifndef MSP_GL_TECHNIQUE_H_
2 #define MSP_GL_TECHNIQUE_H_
3
4 #include "renderpass.h"
5 #include "tag.h"
6
7 namespace Msp {
8 namespace GL {
9
10 class Material;
11 class Texture;
12
13 /**
14 Ties multiple tagged render passes together.
15 */
16 class Technique
17 {
18 public:
19         class Loader: public Msp::DataFile::CollectionObjectLoader<Technique>
20         {
21         private:
22                 static ActionMap shared_actions;
23
24         public:
25                 Loader(Technique &);
26                 Loader(Technique &, Collection &);
27
28         private:
29                 virtual void init_actions();
30
31                 void inherit(const std::string &);
32                 void pass(const std::string &);
33         };
34
35 private:
36         class InheritLoader: public Msp::DataFile::CollectionObjectLoader<Technique>
37         {
38         public:
39                 InheritLoader(Technique &, Collection &);
40
41         private:
42                 void material(const std::string &, const std::string &);
43                 void texture(const std::string &, const std::string &);
44                 void uniforms();
45         };
46
47 public:
48         typedef std::map<Tag, RenderPass> PassMap;
49
50 private:
51         PassMap passes;
52
53 public:
54         RenderPass &add_pass(Tag);
55         bool has_pass(Tag) const;
56         const RenderPass &get_pass(Tag) const;
57         const RenderPass *find_pass(Tag) const;
58         const PassMap &get_passes() const { return passes; }
59         bool replace_texture(const std::string &, const Texture &);
60         bool replace_material(const std::string &, const Material &);
61         bool replace_uniforms(const ProgramData &);
62         bool has_shaders() const;
63 };
64
65 } // namespace GL
66 } // namespace Msp
67
68 #endif