3 #include "complex_modulate_effect.h"
4 #include "effect_chain.h"
5 #include "effect_util.h"
12 ComplexModulateEffect::ComplexModulateEffect()
13 : num_repeats_x(1), num_repeats_y(1)
15 register_int("num_repeats_x", &num_repeats_x);
16 register_int("num_repeats_y", &num_repeats_y);
19 string ComplexModulateEffect::output_fragment_shader()
21 return read_file("complex_modulate_effect.frag");
24 void ComplexModulateEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
26 Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
28 float num_repeats[] = { float(num_repeats_x), float(num_repeats_y) };
29 set_uniform_vec2(glsl_program_num, prefix, "num_repeats", num_repeats);
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));
35 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
37 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
39 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
41 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
45 void ComplexModulateEffect::inform_input_size(unsigned input_num, unsigned width, unsigned height)
48 primary_input_width = width;
49 primary_input_height = height;
53 void ComplexModulateEffect::get_output_size(unsigned *width, unsigned *height,
54 unsigned *virtual_width, unsigned *virtual_height) const
56 *width = *virtual_width = primary_input_width;
57 *height = *virtual_height = primary_input_height;