Move to 'using namespace std;' in all .cpp files.
[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 using namespace std;
9
10 VignetteEffect::VignetteEffect()
11         : center(0.5f, 0.5f),
12           aspect_correction(1.0f, 1.0f),
13           radius(0.3f),
14           inner_radius(0.3f)
15 {
16         register_vec2("center", (float *)&center);
17         register_float("radius", (float *)&radius);
18         register_float("inner_radius", (float *)&inner_radius);
19 }
20
21 string VignetteEffect::output_fragment_shader()
22 {
23         return read_file("vignette_effect.frag");
24 }
25
26 void VignetteEffect::inform_input_size(unsigned input_num, unsigned width, unsigned height) {
27         assert(input_num == 0);
28         if (width >= height) {
29                 aspect_correction = Point2D(float(width) / float(height), 1.0f);
30         } else {
31                 aspect_correction = Point2D(1.0f, float(height) / float(width));
32         }
33 }
34
35 void VignetteEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
36 {
37         Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
38
39         set_uniform_float(glsl_program_num, prefix, "pihalf_div_radius", 0.5 * M_PI / radius);
40         set_uniform_vec2(glsl_program_num, prefix, "aspect_correction", (float *)&aspect_correction);
41
42         Point2D flipped_center(center.x, 1.0f - center.y);
43         set_uniform_vec2(glsl_program_num, prefix, "flipped_center", (float *)&flipped_center);
44 }