1 #ifndef MSP_GL_SEQUENCE_H_
2 #define MSP_GL_SEQUENCE_H_
8 #include "framebuffer.h"
9 #include "renderable.h"
10 #include "rendertarget.h"
11 #include "stenciltest.h"
12 #include "texture2d.h"
25 Top-level content class. Typically a Sequence is used as the content
26 Renderable for a View or effects such as ShadowMap or EnvironmentMap.
28 A Sequence consists of a number of steps. Each step is defined with a
29 Renderable and a tag to render it with and may also have Lighting, Clipping,
30 DepthTest and Blend states. Scenes can be used to further organize Renderables
33 PostProcessors can be applied after all of the steps in the Sequence have been
34 processed. Framebuffer objects are automatically used to pass render results
35 to the PostProcessors. High dynamic range and multisample rendering can be
36 requested for increased quality.
38 class Sequence: public Renderable
45 const Lighting *lighting;
47 StencilTest stencil_test;
49 const Clipping *clipping;
50 Renderable *renderable;
53 Step(Tag, Renderable *);
55 Tag get_tag() const { return tag; }
57 void set_lighting(const Lighting *);
58 void set_depth_test(const DepthTest &);
59 void set_stencil_test(const StencilTest &);
60 void set_blend(const Blend &);
61 void set_clipping(const Clipping *);
62 const Lighting *get_lighting() const { return lighting; }
63 const DepthTest &get_depth_test() const { return depth_test; }
64 const StencilTest &get_stencil_test() const { return stencil_test; }
65 const Blend &get_blend() const { return blend; }
66 const Clipping *get_clipping() const { return clipping; }
67 Renderable *get_renderable() const { return renderable; }
73 PostProcessor *postproc;
76 PostProcStep(PostProcessor *pp, bool o): postproc(pp), owned(o) { }
79 std::vector<Step> steps;
80 std::vector<PostProcStep> postproc;
86 RenderTarget *target[2];
87 RenderTarget *target_ms;
88 std::string debug_name;
91 Sequence(unsigned, unsigned, bool = false);
92 Sequence(const View &);
93 Sequence(const Framebuffer &);
95 void init(unsigned, unsigned);
99 /* Sets high dynamic range mode. Requires floating-point texture support.
100 A ColorCurve postprocessor is recommended for full benefit. */
103 /* Enable or disable alpha channel. When enabled, all render targets are
104 created with an RGBA pixel format instead of RGB. */
105 void set_alpha(bool);
107 void set_multisample(unsigned);
109 unsigned get_width() const { return width; }
110 unsigned get_height() const { return height; }
111 bool get_hdr() const { return hdr; }
112 unsigned get_multisample() const { return samples; }
114 /** Adds a step to the sequence. It's permissible to add the same
115 Renderable multiple times. */
116 Step &add_step(Tag, Renderable &);
118 /** Adds a postprocessor to the sequence. */
119 void add_postprocessor(PostProcessor &);
121 /** Adds a postprocessor to the sequence, transferring ownership. The
122 postprocessor will be deleted together with with sequence. 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();
133 virtual void render(Renderer &, Tag tag = Tag()) const;
136 void create_targets(unsigned);
139 void set_debug_name(const std::string &);
141 void set_target_debug_names();