]> git.tdb.fi Git - libs/gl.git/blob - source/pipeline.h
Move PipelinePass inside Pipeline and make the data members private
[libs/gl.git] / source / pipeline.h
1 #ifndef MSP_GL_PIPELINE_H_
2 #define MSP_GL_PIPELINE_H_
3
4 #include <map>
5 #include <set>
6 #include "renderable.h"
7
8 namespace Msp {
9 namespace GL {
10
11 class Blend;
12 class Camera;
13 class DepthTest;
14 class Framebuffer;
15 class Lighting;
16 class PostProcessor;
17 class Renderbuffer;
18 class Texture2D;
19
20 class Pipeline: public Renderable
21 {
22 public:
23         class Pass
24         {
25         private:
26                 const Lighting *lighting;
27                 const DepthTest *depth_test;
28                 const Blend *blend;
29
30         public:
31                 Pass();
32
33                 void set_lighting(const Lighting *);
34                 void set_depth_test(const DepthTest *);
35                 void set_blend(const Blend *);
36                 const Lighting *get_lighting() const { return lighting; }
37                 const DepthTest *get_depth_test() const { return depth_test; }
38                 const Blend *get_blend() const { return blend; }
39         };
40
41 private:
42         struct Slot
43         {
44                 const Renderable *renderable;
45                 std::set<Tag> passes;
46
47                 Slot(const Renderable *);
48         };
49
50         typedef std::map<Tag, Pass> PassMap;
51
52         PassMap passes;
53         std::vector<Tag> pass_order;
54         const Camera *camera;
55         std::vector<Slot> renderables;
56         std::vector<PostProcessor *> postproc;
57         unsigned width;
58         unsigned height;
59         bool hdr;
60         unsigned samples;
61         Framebuffer *fbo;
62         Texture2D *color_buf;
63         Texture2D *depth_buf;
64         Framebuffer *fbo_ms;
65         Renderbuffer *color_buf_ms;
66         Renderbuffer *depth_buf_ms;
67
68 public:
69         Pipeline(unsigned, unsigned, bool = false);
70         ~Pipeline();
71
72         void set_hdr(bool);
73         void set_multisample(unsigned);
74         void set_camera(const Camera *);
75
76         Pass &add_pass(const Tag &tag);
77         Pass &get_pass(const Tag &tag);
78         const Pass &get_pass(const Tag &tag) const;
79
80         void add_renderable(const Renderable &);
81         void add_renderable_for_pass(const Renderable &, const Tag &);
82         void remove_renderable(const Renderable &);
83         void add_postprocessor(PostProcessor &);
84
85         virtual void render(Renderer &, const Tag &tag = Tag()) const;
86         void render_all() const;
87
88 private:
89         void create_fbos();
90 };
91
92 } // namespace GL
93 } // namespace Msp
94
95 #endif