bbd61da4a41a528abc9e33ae40baec5ba735833e
[movit] / vignette_effect.cpp
1 #include <GL/glew.h>
2 #include <math.h>
3
4 #include "vignette_effect.h"
5 #include "util.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, "pihalf_div_radius", 0.5 * M_PI / 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 }