]> git.sesse.net Git - movit/blob - lift_gamma_gain_effect.cpp
Send the right inv_gamma_22 variable to the uniforms.
[movit] / lift_gamma_gain_effect.cpp
1 #define GL_GLEXT_PROTOTYPES 1
2
3 #include <math.h>
4 #include <GL/gl.h>
5 #include <GL/glext.h>
6
7 #include "lift_gamma_gain_effect.h"
8 #include "util.h"
9
10 LiftGammaGainEffect::LiftGammaGainEffect()
11         : lift(0.0f, 0.0f, 0.0f),
12           gamma(1.0f, 1.0f, 1.0f),
13           gain(1.0f, 1.0f, 1.0f),
14           saturation(1.0f)
15 {
16         register_vec3("lift", (float *)&lift);
17         register_vec3("gamma", (float *)&gamma);
18         register_vec3("gain", (float *)&gain);
19         register_float("saturation", &saturation);
20 }
21
22 std::string LiftGammaGainEffect::output_glsl()
23 {
24         return read_file("lift_gamma_gain_effect.glsl");
25 }
26
27 void LiftGammaGainEffect::set_uniforms(GLhandleARB glsl_program_num, const std::string &prefix)
28 {
29         Effect::set_uniforms(glsl_program_num, prefix);
30
31         RGBTriplet gain_pow_inv_gamma(
32                 pow(gain.r, 1.0f / gamma.r),
33                 pow(gain.g, 1.0f / gamma.g),
34                 pow(gain.b, 1.0f / gamma.b));
35         set_uniform_vec3(glsl_program_num, prefix, "gain_pow_inv_gamma", (float *)&gain_pow_inv_gamma);
36
37         RGBTriplet inv_gamma_22(
38                 2.2f / gamma.r,
39                 2.2f / gamma.g,
40                 2.2f / gamma.b);
41         set_uniform_vec3(glsl_program_num, prefix, "inv_gamma_22", (float *)&inv_gamma_22);
42 }