]> git.tdb.fi Git - libs/gl.git/blob - source/postprocessor.h
Improve formatting of an empty loop body
[libs/gl.git] / source / postprocessor.h
1 #ifndef MSP_GL_POSTPROCESSOR_H_
2 #define MSP_GL_POSTPROCESSOR_H_
3
4 #include <msp/datafile/objectloader.h>
5
6 namespace Msp {
7 namespace GL {
8
9 class Mesh;
10 class Renderer;
11 class Shader;
12 class Texture2D;
13
14 /**
15 Base class for post-processing effects.  Post-processors receive the contents
16 of the entire framebuffer as a texture and render it back, altering it in the
17 process.
18 */
19 class PostProcessor
20 {
21 public:
22         struct Template
23         {
24                 class Loader: public Msp::DataFile::ObjectLoader<Template>
25                 {
26                 public:
27                         Loader(Template &);
28                 };
29
30                 unsigned size_divisor;
31
32                 Template();
33                 virtual ~Template() { }
34
35                 virtual PostProcessor *create(unsigned, unsigned) const = 0;
36         };
37
38 protected:
39         PostProcessor() { }
40 public:
41         virtual ~PostProcessor() { }
42
43         /// Renders the effect.
44         virtual void render(const Texture2D &, const Texture2D &) { }
45
46         virtual void render(Renderer &, const Texture2D &, const Texture2D &);
47
48 protected:
49         /** Returns a vertex shader suitable for rendering a full-screen quad.
50         Input vertices are assumed to be in normalized device coordinates; no
51         transform is performed.  The shader provides a varying vec2 texcoord for
52         a fragment shader to access textures.
53         
54         Deprecated in favor of the builtin postprocess.glsl module. */
55         static Shader &get_fullscreen_vertex_shader();
56
57         /** Returns a mesh consisting of a single quad, covering the entire screen.
58         The vertices are in normalized device coordinates. */
59         static const Mesh &get_fullscreen_quad();
60
61 private:
62         static const Mesh &create_fullscreen_quad();
63 };
64
65 } // namespace GL
66 } // namespace Msp
67
68 #endif