]> git.tdb.fi Git - libs/gl.git/blob - source/effects/postprocessor.h
Rearrange soucre files into subdirectories
[libs/gl.git] / source / effects / 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 Sampler;
12 class Shader;
13 class Texture2D;
14
15 /**
16 Base class for post-processing effects.  Post-processors receive the contents
17 of the entire framebuffer as a texture and render it back, altering it in the
18 process.
19 */
20 class PostProcessor
21 {
22 public:
23         struct Template
24         {
25                 class Loader: public Msp::DataFile::ObjectLoader<Template>
26                 {
27                 public:
28                         Loader(Template &);
29                 };
30
31                 unsigned size_divisor;
32
33                 Template();
34                 virtual ~Template() { }
35
36                 virtual PostProcessor *create(unsigned, unsigned) const = 0;
37         };
38
39 private:
40         static WeakPtr<Mesh> fullscreen_quad;
41         static WeakPtr<Sampler> nearest_sampler;
42         static WeakPtr<Sampler> linear_sampler;
43
44 protected:
45         PostProcessor() { }
46 public:
47         virtual ~PostProcessor() { }
48
49         /// Renders the effect.
50         virtual void render(const Texture2D &, const Texture2D &) { }
51
52         virtual void render(Renderer &, const Texture2D &, const Texture2D &);
53
54 protected:
55         /** Returns a mesh consisting of a single quad, covering the entire screen.
56         The vertices are in normalized device coordinates. */
57         static RefPtr<Mesh> get_fullscreen_quad();
58
59         static RefPtr<Sampler> get_nearest_sampler();
60         static RefPtr<Sampler> get_linear_sampler();
61 };
62
63 } // namespace GL
64 } // namespace Msp
65
66 #endif