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, combining Renderables
24 with a camera, lights and some other influential objects.
26 A Pipeline is also a Renderable itself. Externally, it only exposes the
27 default pass. Internally, it can hold any number of passes, which are invoked
28 in sequence when rendering the default pass is requested. Each pass can have a
29 Lighting, a DepthTest and a Blend to control how it is rendered.
31 A Pipeline's render method should normally be called without a Renderer; it
32 will create one itself, using the camera specified for the Pipeline. If a
33 Renderer is passed, its camera will be used instead.
35 Renderables are rendered in the order they were added to the Pipeline. While
36 it's possible to remove renderables as well, using a Scene is recommended if
37 frequent add/remove operations are needed.
39 Pipelines may have post-processors to apply full-screen effects. Framebuffer
40 objects are automatically used to pass render results to the post-processors.
41 High dynamic range and multisample rendering can also be used.
43 class Pipeline: public Renderable
50 const Lighting *lighting;
51 const DepthTest *depth_test;
53 const Clipping *clipping;
58 const Tag &get_tag() const { return tag; }
60 void set_lighting(const Lighting *);
61 void set_depth_test(const DepthTest *);
62 void set_blend(const Blend *);
63 void set_clipping(const Clipping *);
64 const Lighting *get_lighting() const { return lighting; }
65 const DepthTest *get_depth_test() const { return depth_test; }
66 const Blend *get_blend() const { return blend; }
67 const Clipping *get_clipping() const { return clipping; }
73 const Renderable *renderable;
76 Slot(const Renderable *);
85 RenderTarget(unsigned, unsigned, PixelFormat);
88 struct MultisampleTarget
94 MultisampleTarget(unsigned, unsigned, unsigned, PixelFormat);
97 typedef std::list<Pass> PassList;
100 const Camera *camera;
101 std::vector<Slot> renderables;
102 std::vector<PostProcessor *> postproc;
107 RenderTarget *target[2];
108 MultisampleTarget *target_ms;
109 mutable bool in_frame;
112 Pipeline(unsigned, unsigned, bool = false);
116 void set_multisample(unsigned);
117 void set_camera(const Camera *);
119 Pass &add_pass(const Tag &tag);
121 void add_renderable(const Renderable &);
122 void add_renderable_for_pass(const Renderable &, const Tag &);
123 void remove_renderable(const Renderable &);
124 void add_postprocessor(PostProcessor &);
126 virtual void setup_frame() const;
127 virtual void finish_frame() const;
129 virtual void render(const Tag &tag = Tag()) const;
130 virtual void render(Renderer &, const Tag &tag = Tag()) const;
133 void create_targets(unsigned);