]> git.tdb.fi Git - libs/gl.git/blob - source/renderpass.h
Drop Id tags and copyright notices from files
[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 TexEnv;
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                 RefPtr<TexEnv> env;
49
50         public:
51                 TextureLoader(Texturing &, unsigned, Collection *);
52         private:
53                 virtual void finish();
54
55                 void texenv();
56                 void texture(const std::string &);
57                 void texture2d();
58         };
59
60         Program *shprog;
61         ProgramData *shdata;
62         RefPtr<const Material> material;
63         Texturing *texturing;
64         std::map<std::string, unsigned> tex_names;
65
66         RenderPass &operator=(const RenderPass &);
67 public:
68         RenderPass();
69         RenderPass(const RenderPass &);
70         ~RenderPass();
71
72         const Program *get_shader_program() const { return shprog; }
73         const ProgramData *get_shader_data() const { return shdata; }
74         void set_material(const Material *);
75         const Material *get_material() const { return material.get(); }
76         void set_texture(unsigned, const Texture *);
77         const Texturing *get_texturing() const { return texturing; }
78         int get_texture_index(const std::string &) const;
79 };
80
81 } // namespace GL
82 } // namespace Msp
83
84 #endif