1 #ifndef MSP_GL_PIPELINE_H_
2 #define MSP_GL_PIPELINE_H_
6 #include "framebuffer.h"
7 #include "renderable.h"
8 #include "renderbuffer.h"
9 #include "rendertarget.h"
10 #include "texture2d.h"
24 Top-level content class. Typically a Pipeline is used as the content
25 Renderable for a View or effects such as ShadowMap or EnvironmentMap.
27 A Pipeline contains a sequence of passes. Each pass has a Renderable along
28 with Lighting, Clipping, DepthTest and Blend states. Scenes can be used to
29 organize Renderables within a pass.
31 PostProcessors can be applied after all of the passes in the Pipeline have been
32 rendered. Framebuffer objects are automatically used to pass render results to
33 the PostProcessors. High dynamic range and multisample rendering can be
34 requested for increased quality.
36 class Pipeline: public Renderable
43 const Lighting *lighting;
44 const DepthTest *depth_test;
46 const Clipping *clipping;
47 Renderable *renderable;
50 Pass(const Tag &, Renderable *);
52 const Tag &get_tag() const { return tag; }
54 void set_lighting(const Lighting *);
55 void set_depth_test(const DepthTest *);
56 void set_blend(const Blend *);
57 void set_clipping(const Clipping *);
58 const Lighting *get_lighting() const { return lighting; }
59 const DepthTest *get_depth_test() const { return depth_test; }
60 const Blend *get_blend() const { return blend; }
61 const Clipping *get_clipping() const { return clipping; }
62 Renderable *get_renderable() const { return renderable; }
68 Renderable *renderable;
74 typedef std::list<Pass> PassList;
78 std::vector<Slot> renderables;
79 std::vector<RefPtr<PostProcessor> > postproc;
84 RenderTarget *target[2];
85 RenderTarget *target_ms;
88 Pipeline(unsigned, unsigned, bool = false);
89 Pipeline(const View &);
90 Pipeline(const Framebuffer &);
92 void init(unsigned, unsigned);
96 /* Sets high dynamic range mode. Requires floating-point texture support.
97 A ColorCurve postprocessor is recommended for full benefit. */
100 void set_multisample(unsigned);
102 unsigned get_width() const { return width; }
103 unsigned get_height() const { return height; }
104 bool get_hdr() const { return hdr; }
105 unsigned get_multisample() const { return samples; }
108 void set_camera(const Camera *);
109 Pass &add_pass(const Tag &tag);
110 void add_renderable(Renderable &);
111 void add_renderable_for_pass(Renderable &, const Tag &);
112 void remove_renderable(Renderable &);
114 /** Adds a pass to the pipeline. It's permissible to add the same
115 Renderable multiple times. */
116 Pass &add_pass(const Tag &, Renderable &);
118 /** Adds a postprocessor to the pipeline. */
119 void add_postprocessor(PostProcessor &);
121 /** Adds a postprocessor to the pipeline, transferring ownership. The
122 postprocessor will be deleted together with with pipeline. It is also
123 deleted if this call throws an exception. */
124 void add_postprocessor_owned(PostProcessor *);
127 void add_postprocessor(PostProcessor *, bool);
130 virtual void setup_frame(Renderer &);
131 virtual void finish_frame();
134 virtual void render(Renderer &, const Tag &tag = Tag()) const;
137 void create_targets(unsigned);