]> git.tdb.fi Git - libs/gl.git/blob - source/postprocessor.h
d9489de2c65999a73644df932fe17c26f442d519
[libs/gl.git] / source / postprocessor.h
1 #ifndef MSP_GL_POSTPROCESSOR_H_
2 #define MSP_GL_POSTPROCESSOR_H_
3
4 namespace Msp {
5 namespace GL {
6
7 class Mesh;
8 class Shader;
9 class Texture2D;
10
11 /**
12 Base class for post-processing effects.  Post-processors receive the contents
13 of the entire framebuffer as a texture and render it back, altering it in the
14 process.
15 */
16 class PostProcessor
17 {
18 protected:
19         PostProcessor() { }
20 public:
21         virtual ~PostProcessor() { }
22
23         /// Renders the effect.
24         virtual void render(const Texture2D &color, const Texture2D &depth) = 0;
25
26 protected:
27         /** Returns a vertex shader suitable for rendering a fullscreen quad.  Input
28         vertices are assumed to be in normalized device coordinates; no transform is
29         done.  The shader provides a varying vec2 texcoord for fragment a shader to
30         access textures. */
31         static Shader &get_fullscreen_vertex_shader();
32
33         /** Returns a mesh consisting of a single quad, covering the entire screen.
34         The vertices are in normalized device coordinates. */
35         static const Mesh &get_fullscreen_quad();
36
37 private:
38         static const Mesh &create_fullscreen_quad();
39 };
40
41 } // namespace GL
42 } // namespace Msp
43
44 #endif