Split out some private utilities into effect_util.cpp, so we do not need to include...
[movit] / vignette_effect.cpp
1 #include <GL/glew.h>
2 #include <math.h>
3
4 #include "effect_util.h"
5 #include "vignette_effect.h"
6 #include "util.h"
7
8 VignetteEffect::VignetteEffect()
9         : center(0.5f, 0.5f),
10           radius(0.3f),
11           inner_radius(0.3f)
12 {
13         register_vec2("center", (float *)&center);
14         register_float("radius", (float *)&radius);
15         register_float("inner_radius", (float *)&inner_radius);
16 }
17
18 std::string VignetteEffect::output_fragment_shader()
19 {
20         return read_file("vignette_effect.frag");
21 }
22
23 void VignetteEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num)
24 {
25         Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
26
27         set_uniform_float(glsl_program_num, prefix, "pihalf_div_radius", 0.5 * M_PI / radius);
28
29         Point2D aspect(16.0f / 9.0f, 1.0f);  // FIXME
30         set_uniform_vec2(glsl_program_num, prefix, "aspect_correction", (float *)&aspect);
31 }