]> git.tdb.fi Git - libs/gl.git/blob - source/pipeline.h
Support limiting renderables in Pipeline to specific passes
[libs/gl.git] / source / pipeline.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2009  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         Framebuffer *fbo;
49         Texture2D *color_buf;
50         Renderbuffer *depth_buf;
51
52 public:
53         Pipeline(unsigned, unsigned, bool);
54         ~Pipeline();
55
56         void set_camera(const Camera *);
57
58         PipelinePass &add_pass(const Tag &tag);
59         PipelinePass &get_pass(const Tag &tag);
60         const PipelinePass &get_pass(const Tag &tag) const;
61
62         void add_renderable(const Renderable &);
63         void add_renderable_for_pass(const Renderable &, const Tag &);
64         void remove_renderable(const Renderable &);
65         void add_effect(Effect &);
66         void add_postprocessor(PostProcessor &);
67
68         virtual void render(const Tag &tag = Tag()) const;
69         void render_all() const;
70 };
71
72 } // namespace GL
73 } // namespace Msp
74
75 #endif