]> git.tdb.fi Git - libs/gl.git/blob - source/renderpass.h
Add const overload for AnimatedObject::get_shader_data
[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 #include "bindable.h"
7
8 namespace Msp {
9 namespace GL {
10
11 class Material;
12 class Program;
13 class ProgramData;
14 class Renderer;
15 class Texture;
16 class Texturing;
17
18 /**
19 Encapsulates the data that determines the appearance of a rendered surface.
20 This includes shader and data for it, material and texturing.
21
22 XXX Does not delete inline texture from datafiles properly
23 */
24 class RenderPass
25 {
26 public:
27         class Loader: public DataFile::CollectionObjectLoader<RenderPass>
28         {
29         public:
30                 Loader(RenderPass &);
31                 Loader(RenderPass &, Collection &);
32
33         private:
34                 void init();
35                 void material_inline();
36                 void material(const std::string &);
37                 void texunit(unsigned);
38                 void texunit_named(unsigned, const std::string &);
39                 void uniforms();
40         };
41
42 private:
43         struct TextureLoader: public DataFile::CollectionObjectLoader<Texturing>
44         {
45         private:
46                 unsigned index;
47                 RefPtr<Texture> tex;
48
49         public:
50                 TextureLoader(Texturing &, unsigned, Collection *);
51         private:
52                 virtual void finish();
53
54                 void texture(const std::string &);
55                 void texture2d();
56         };
57
58         const Program *shprog;
59         ProgramData *shdata;
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         void set_shader_program(const Program *, const ProgramData *);
73         const Program *get_shader_program() const { return shprog; }
74         const ProgramData *get_shader_data() const { return shdata; }
75         void set_material(const Material *);
76         const Material *get_material() const { return material.get(); }
77         const std::string &get_material_slot_name() const { return material_slot; }
78         void set_texture(unsigned, const Texture *);
79         const Texturing *get_texturing() const { return texturing; }
80         int get_texture_index(const std::string &) const;
81         void set_back_faces(bool);
82         bool get_back_faces() const { return back_faces; }
83
84         void apply(Renderer &) const;
85 };
86
87 } // namespace GL
88 } // namespace Msp
89
90 #endif