]> git.tdb.fi Git - libs/gl.git/blob - source/pipeline.h
f7f7e06ca198d84fe0a7b0aad583898f3eabd6cc
[libs/gl.git] / source / pipeline.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2009-2011  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_PIPELINE_H_
9 #define MSP_GL_PIPELINE_H_
10
11 #include <map>
12 #include <set>
13 #include "pipelinepass.h"
14 #include "renderable.h"
15
16 namespace Msp {
17 namespace GL {
18
19 class Camera;
20 class Effect;
21 class Framebuffer;
22 class PostProcessor;
23 class Renderbuffer;
24 class Texture2D;
25
26 class Pipeline: public Renderable
27 {
28 private:
29         struct Slot
30         {
31                 const Renderable *renderable;
32                 std::set<Tag> passes;
33
34                 Slot(const Renderable *);
35         };
36
37         typedef std::map<Tag, PipelinePass> PassMap;
38
39         PassMap passes;
40         std::vector<Tag> pass_order;
41         const Camera *camera;
42         std::vector<Slot> renderables;
43         std::vector<Effect *> effects;
44         std::vector<PostProcessor *> postproc;
45         unsigned width;
46         unsigned height;
47         bool hdr;
48         unsigned samples;
49         Framebuffer *fbo;
50         Texture2D *color_buf;
51         Texture2D *depth_buf;
52         Framebuffer *fbo_ms;
53         Renderbuffer *color_buf_ms;
54         Renderbuffer *depth_buf_ms;
55
56 public:
57         Pipeline(unsigned, unsigned, bool = false);
58         ~Pipeline();
59
60         void set_hdr(bool);
61         void set_multisample(unsigned);
62         void set_camera(const Camera *);
63
64         PipelinePass &add_pass(const Tag &tag);
65         PipelinePass &get_pass(const Tag &tag);
66         const PipelinePass &get_pass(const Tag &tag) const;
67
68         void add_renderable(const Renderable &);
69         void add_renderable_for_pass(const Renderable &, const Tag &);
70         void remove_renderable(const Renderable &);
71         void add_effect(Effect &);
72         void add_postprocessor(PostProcessor &);
73
74         virtual void render(Renderer &, const Tag &tag = Tag()) const;
75         void render_all() const;
76
77 private:
78         void create_fbos();
79 };
80
81 } // namespace GL
82 } // namespace Msp
83
84 #endif