]> git.tdb.fi Git - libs/gl.git/blob - source/pipeline.h
Turn Effect into a Renderable
[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 "pipelinepass.h"
7 #include "renderable.h"
8
9 namespace Msp {
10 namespace GL {
11
12 class Camera;
13 class Framebuffer;
14 class PostProcessor;
15 class Renderbuffer;
16 class Texture2D;
17
18 class Pipeline: public Renderable
19 {
20 private:
21         struct Slot
22         {
23                 const Renderable *renderable;
24                 std::set<Tag> passes;
25
26                 Slot(const Renderable *);
27         };
28
29         typedef std::map<Tag, PipelinePass> PassMap;
30
31         PassMap passes;
32         std::vector<Tag> pass_order;
33         const Camera *camera;
34         std::vector<Slot> renderables;
35         std::vector<PostProcessor *> postproc;
36         unsigned width;
37         unsigned height;
38         bool hdr;
39         unsigned samples;
40         Framebuffer *fbo;
41         Texture2D *color_buf;
42         Texture2D *depth_buf;
43         Framebuffer *fbo_ms;
44         Renderbuffer *color_buf_ms;
45         Renderbuffer *depth_buf_ms;
46
47 public:
48         Pipeline(unsigned, unsigned, bool = false);
49         ~Pipeline();
50
51         void set_hdr(bool);
52         void set_multisample(unsigned);
53         void set_camera(const Camera *);
54
55         PipelinePass &add_pass(const Tag &tag);
56         PipelinePass &get_pass(const Tag &tag);
57         const PipelinePass &get_pass(const Tag &tag) const;
58
59         void add_renderable(const Renderable &);
60         void add_renderable_for_pass(const Renderable &, const Tag &);
61         void remove_renderable(const Renderable &);
62         void add_postprocessor(PostProcessor &);
63
64         virtual void render(Renderer &, const Tag &tag = Tag()) const;
65         void render_all() const;
66
67 private:
68         void create_fbos();
69 };
70
71 } // namespace GL
72 } // namespace Msp
73
74 #endif