1 #ifndef MSP_GL_PIPELINE_H_
2 #define MSP_GL_PIPELINE_H_
6 #include "framebuffer.h"
7 #include "renderable.h"
8 #include "renderbuffer.h"
22 Encapsulates all of the information used to produce a complete image in the
23 framebuffer. This is the highest level rendering class.
25 A Pipeline contains a sequence of passes. Each pass has a Renderable along
26 with Lighting, Clipping, DepthTest and Blend states. Scenes can be used to
27 organize Renderables within a pass. A Camera can be specified for the entire
30 A Pipeline is also a Renderable itself. It will only respond to the default
31 pass. The Renderables within the Pipeline will be invoked with whatever tags
32 were specified when adding them.
34 A Pipeline's render method should normally be called without a Renderer; it
35 will create one itself, using the camera specified for the Pipeline. If a
36 Renderer is passed, its camera will be used instead.
38 PostProcessors can be applied after all of the passes in the Pipeline have been
39 rendered. Framebuffer objects are automatically used to pass render results to
40 the PostProcessors. High dynamic range and multisample rendering can be
41 requested for increased quality.
43 class Pipeline: public Renderable
50 const Lighting *lighting;
51 const DepthTest *depth_test;
53 const Clipping *clipping;
54 const Renderable *renderable;
57 Pass(const Tag &, const Renderable *);
59 const Tag &get_tag() const { return tag; }
61 void set_lighting(const Lighting *);
62 void set_depth_test(const DepthTest *);
63 void set_blend(const Blend *);
64 void set_clipping(const Clipping *);
65 const Lighting *get_lighting() const { return lighting; }
66 const DepthTest *get_depth_test() const { return depth_test; }
67 const Blend *get_blend() const { return blend; }
68 const Clipping *get_clipping() const { return clipping; }
69 const Renderable *get_renderable() const { return renderable; }
75 const Renderable *renderable;
78 Slot(const Renderable *);
87 RenderTarget(unsigned, unsigned, PixelFormat);
90 struct MultisampleTarget
96 MultisampleTarget(unsigned, unsigned, unsigned, PixelFormat);
99 typedef std::list<Pass> PassList;
102 const Camera *camera;
103 std::vector<Slot> renderables;
104 std::vector<PostProcessor *> postproc;
109 RenderTarget *target[2];
110 MultisampleTarget *target_ms;
111 mutable bool in_frame;
114 Pipeline(unsigned, unsigned, bool = false);
118 void set_multisample(unsigned);
119 void set_camera(const Camera *);
122 Pass &add_pass(const Tag &tag);
123 void add_renderable(const Renderable &);
124 void add_renderable_for_pass(const Renderable &, const Tag &);
125 void remove_renderable(const Renderable &);
127 /** Adds a pass to the pipeline. It's permissible to add the same
128 Renderable multiple times. */
129 Pass &add_pass(const Tag &, const Renderable &);
131 /** Adds a postprocessor to the pipeline. */
132 void add_postprocessor(PostProcessor &);
134 virtual void setup_frame() const;
135 virtual void finish_frame() const;
137 virtual void render(const Tag &tag = Tag()) const;
138 virtual void render(Renderer &, const Tag &tag = Tag()) const;
141 void create_targets(unsigned);