]> git.sesse.net Git - movit/blob - vignette_effect.cpp
4ac564a1f6a720219afe4cd11fd9d013b0191dce
[movit] / vignette_effect.cpp
1 #include <math.h>
2
3 #include "vignette_effect.h"
4 #include "util.h"
5 #include "opengl.h"
6
7 VignetteEffect::VignetteEffect()
8         : center(0.5f, 0.5f),
9           radius(0.3f),
10           inner_radius(0.3f)
11 {
12         register_vec2("center", (float *)&center);
13         register_float("radius", (float *)&radius);
14         register_float("inner_radius", (float *)&inner_radius);
15 }
16
17 std::string VignetteEffect::output_fragment_shader()
18 {
19         return read_file("vignette_effect.frag");
20 }
21
22 void VignetteEffect::set_gl_state(GLuint glsl_program_num, const std::string &prefix, unsigned *sampler_num)
23 {
24         Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
25
26         set_uniform_float(glsl_program_num, prefix, "inv_radius", 1.0f / radius);
27
28         Point2D aspect(16.0f / 9.0f, 1.0f);  // FIXME
29         set_uniform_vec2(glsl_program_num, prefix, "aspect_correction", (float *)&aspect);
30 }