]> git.sesse.net Git - movit/blob - blur_effect.h
Let SDL convert the pixels instead of doing it ourselves.
[movit] / blur_effect.h
1 #ifndef _BLUR_EFFECT_H
2 #define _BLUR_EFFECT_H 1
3
4 // A separable 2D blur implemented by a combination of mipmap filtering
5 // and convolution (essentially giving a convolution with a piecewise linear
6 // approximation to the true impulse response).
7 //
8 // Works in two passes; first horizontal, then vertical (BlurEffect,
9 // which is what the user is intended to use, instantiates two copies of
10 // SingleBlurPassEffect behind the scenes).
11
12 #include "effect.h"
13
14 class SingleBlurPassEffect;
15
16 class BlurEffect : public Effect {
17 public:
18         BlurEffect();
19
20         virtual std::string output_fragment_shader() {
21                 assert(false);
22         }
23         virtual void set_uniforms(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num) {
24                 assert(false);
25         }
26
27         virtual bool needs_many_samples() const { return true; }
28         virtual bool needs_mipmaps() const { return true; }
29         virtual void add_self_to_effect_chain(std::vector<Effect *> *chain);
30         virtual bool set_float(const std::string &key, float value);
31         
32 private:
33         SingleBlurPassEffect *hpass, *vpass;
34 };
35
36 class SingleBlurPassEffect : public Effect {
37 public:
38         SingleBlurPassEffect();
39         std::string output_fragment_shader();
40
41         virtual bool needs_many_samples() const { return true; }
42         virtual bool needs_mipmaps() const { return true; }
43
44         void set_uniforms(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num);
45         
46         enum Direction { HORIZONTAL = 0, VERTICAL = 1 };
47
48 private:
49         float radius;
50         Direction direction;
51 };
52
53 #endif // !defined(_BLUR_EFFECT_H)