]> git.sesse.net Git - movit/blob - complex_modulate_effect.cpp
Properly restore the LC_NUMERIC locale after finalizing.
[movit] / complex_modulate_effect.cpp
1 #include <epoxy/gl.h>
2
3 #include "complex_modulate_effect.h"
4 #include "effect_chain.h"
5 #include "effect_util.h"
6 #include "util.h"
7
8 using namespace std;
9
10 namespace movit {
11
12 ComplexModulateEffect::ComplexModulateEffect()
13         : num_repeats_x(1), num_repeats_y(1)
14 {
15         register_int("num_repeats_x", &num_repeats_x);
16         register_int("num_repeats_y", &num_repeats_y);
17 }
18
19 string ComplexModulateEffect::output_fragment_shader()
20 {
21         return read_file("complex_modulate_effect.frag");
22 }
23
24 void ComplexModulateEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
25 {
26         Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
27
28         float num_repeats[] = { float(num_repeats_x), float(num_repeats_y) };
29         set_uniform_vec2(glsl_program_num, prefix, "num_repeats", num_repeats);
30
31         // Set the secondary input to repeat (and nearest while we're at it).
32         Node *self = chain->find_node_for_effect(this);
33         glActiveTexture(chain->get_input_sampler(self, 1));
34         check_error();
35         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
36         check_error();
37         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
38         check_error();
39         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
40         check_error();
41         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
42         check_error();
43 }
44
45 void ComplexModulateEffect::inform_input_size(unsigned input_num, unsigned width, unsigned height)
46 {
47         if (input_num == 0) {
48                 primary_input_width = width;
49                 primary_input_height = height;
50         }
51 }
52
53 void ComplexModulateEffect::get_output_size(unsigned *width, unsigned *height,
54                                             unsigned *virtual_width, unsigned *virtual_height) const
55 {
56         *width = *virtual_width = primary_input_width;
57         *height = *virtual_height = primary_input_height;
58 }
59
60 }  // namespace movit