1 #ifndef MSP_GL_PIPELINE_H_
2 #define MSP_GL_PIPELINE_H_
6 #include "framebuffer.h"
7 #include "renderable.h"
8 #include "renderbuffer.h"
21 Encapsulates all of the information used to produce a complete image in the
22 framebuffer. This is the highest level rendering class, combining Renderables
23 with a camera, lights and some other influential objects.
25 A Pipeline is also a Renderable itself. Externally, it only exposes the
26 default pass. Internally, it can hold any number of passes, which are invoked
27 in sequence when rendering the default pass is requested. Each pass can have a
28 Lighting, a DepthTest and a Blend to control how it is rendered.
30 A Pipeline's render method should normally be called without a Renderer; it
31 will create one itself, using the camera specified for the Pipeline. If a
32 Renderer is passed, its camera will be used instead.
34 Renderables are rendered in the order they were added to the Pipeline. While
35 it's possible to remove renderables as well, using a Scene is recommended if
36 frequent add/remove operations are needed.
38 Pipelines may have post-processors to apply full-screen effects. Framebuffer
39 objects are automatically used to pass render results to the post-processors.
40 High dynamic range and multisample rendering can also be used.
42 class Pipeline: public Renderable
49 const Lighting *lighting;
50 const DepthTest *depth_test;
56 const Tag &get_tag() const { return tag; }
58 void set_lighting(const Lighting *);
59 void set_depth_test(const DepthTest *);
60 void set_blend(const Blend *);
61 const Lighting *get_lighting() const { return lighting; }
62 const DepthTest *get_depth_test() const { return depth_test; }
63 const Blend *get_blend() const { return blend; }
69 const Renderable *renderable;
72 Slot(const Renderable *);
81 RenderTarget(unsigned, unsigned, PixelFormat);
84 struct MultisampleTarget
90 MultisampleTarget(unsigned, unsigned, unsigned, PixelFormat);
93 typedef std::list<Pass> PassList;
97 std::vector<Slot> renderables;
98 std::vector<PostProcessor *> postproc;
103 RenderTarget *target[2];
104 MultisampleTarget *target_ms;
105 mutable bool in_frame;
108 Pipeline(unsigned, unsigned, bool = false);
112 void set_multisample(unsigned);
113 void set_camera(const Camera *);
115 Pass &add_pass(const Tag &tag);
117 void add_renderable(const Renderable &);
118 void add_renderable_for_pass(const Renderable &, const Tag &);
119 void remove_renderable(const Renderable &);
120 void add_postprocessor(PostProcessor &);
122 virtual void setup_frame() const;
123 virtual void finish_frame() const;
125 virtual void render(const Tag &tag = Tag()) const;
126 virtual void render(Renderer &, const Tag &tag = Tag()) const;
129 void create_targets(unsigned);