]> git.tdb.fi Git - libs/gl.git/blob - source/renderpass.h
Remove support for inline textures in RenderPass
[libs/gl.git] / source / renderpass.h
1 #ifndef MSP_GL_RENDERPASS_H_
2 #define MSP_GL_RENDERPASS_H_
3
4 #include <msp/core/refptr.h>
5 #include <msp/datafile/objectloader.h>
6
7 namespace Msp {
8 namespace GL {
9
10 class Material;
11 class Program;
12 class ProgramData;
13 class Renderer;
14 class Texture;
15 class Texturing;
16
17 /**
18 Encapsulates the data that determines the appearance of a rendered surface.
19 This includes shader and data for it, material and texturing.
20 */
21 class RenderPass
22 {
23 public:
24         class Loader: public DataFile::CollectionObjectLoader<RenderPass>
25         {
26         public:
27                 Loader(RenderPass &);
28                 Loader(RenderPass &, Collection &);
29
30         private:
31                 void init();
32
33                 void material_inline();
34                 void material(const std::string &);
35                 void shader(const std::string &);
36                 void texunit(unsigned);
37                 void texunit_auto(const std::string &);
38                 void texunit_named(unsigned, const std::string &);
39                 void uniforms();
40                 void uniform_slot(const std::string &);
41                 void uniform_slot2(const std::string &, const std::string &);
42         };
43
44 private:
45         struct TextureLoader: public DataFile::CollectionObjectLoader<Texturing>
46         {
47         private:
48                 unsigned index;
49
50         public:
51                 TextureLoader(Texturing &, unsigned, Collection *);
52         private:
53                 void texture(const std::string &);
54         };
55
56         RefPtr<const Program> shprog;
57         bool shprog_from_material;
58         RefPtr<ProgramData> shdata;
59         std::map<std::string, std::string> uniform_slots;
60         RefPtr<const Material> material;
61         std::string material_slot;
62         Texturing *texturing;
63         std::map<std::string, unsigned> tex_names;
64         bool back_faces;
65
66 public:
67         RenderPass();
68         RenderPass(const RenderPass &);
69         RenderPass &operator=(const RenderPass &);
70         ~RenderPass();
71
72 private:
73         void finalize_material(DataFile::Collection *);
74         void maybe_create_material_shader(DataFile::Collection *);
75         void ensure_private_shader_data();
76
77 public:
78         void set_shader_program(const Program *, const ProgramData *);
79         const Program *get_shader_program() const { return shprog.get(); }
80         const ProgramData *get_shader_data() const { return shdata.get(); }
81         const std::string &get_slotted_uniform_name(const std::string &) const;
82         void set_material(const Material *);
83         const Material *get_material() const { return material.get(); }
84         const std::string &get_material_slot_name() const { return material_slot; }
85         void set_texture(unsigned, const Texture *);
86         const Texturing *get_texturing() const { return texturing; }
87         int get_texture_index(const std::string &) const;
88         void set_back_faces(bool);
89         bool get_back_faces() const { return back_faces; }
90
91         void apply(Renderer &) const;
92 };
93
94 } // namespace GL
95 } // namespace Msp
96
97 #endif