Slight cleanup in texture upload format selection.
[movit] / effect_chain.cpp
index 5d9eaa3c596c88671d62dd81d4a22b9c29bee3d0..85832db88541cfb90748dd55f8aca171a6621673 100644 (file)
@@ -14,6 +14,7 @@
 #include "lift_gamma_gain_effect.h"
 #include "colorspace_conversion_effect.h"
 #include "saturation_effect.h"
+#include "vignette_effect.h"
 #include "texture_enum.h"
 
 EffectChain::EffectChain(unsigned width, unsigned height)
@@ -38,10 +39,14 @@ Effect *instantiate_effect(EffectId effect)
                return new GammaExpansionEffect();
        case EFFECT_GAMMA_COMPRESSION:
                return new GammaCompressionEffect();
+       case EFFECT_COLOR_SPACE_CONVERSION:
+               return new ColorSpaceConversionEffect();
        case EFFECT_LIFT_GAMMA_GAIN:
                return new LiftGammaGainEffect();
        case EFFECT_SATURATION:
                return new SaturationEffect();
+       case EFFECT_VIGNETTE:
+               return new VignetteEffect();
        }
        assert(false);
 }
@@ -171,8 +176,8 @@ void EffectChain::finalize()
        printf("%s\n", frag_shader.c_str());
        
        glsl_program_num = glCreateProgram();
-       GLhandleARB vs_obj = compile_shader(read_file("vs.glsl"), GL_VERTEX_SHADER);
-       GLhandleARB fs_obj = compile_shader(frag_shader, GL_FRAGMENT_SHADER);
+       GLuint vs_obj = compile_shader(read_file("vs.glsl"), GL_VERTEX_SHADER);
+       GLuint fs_obj = compile_shader(frag_shader, GL_FRAGMENT_SHADER);
        glAttachShader(glsl_program_num, vs_obj);
        check_error();
        glAttachShader(glsl_program_num, fs_obj);
@@ -194,18 +199,21 @@ void EffectChain::render_to_screen(unsigned char *src)
        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, SOURCE_IMAGE);
 
-       GLenum internal_format = GL_RGBA8;
+       GLenum format, internal_format;
        if (use_srgb_texture_format) {
                internal_format = GL_SRGB8;
+       } else {
+               internal_format = GL_RGBA8;
        }
-
        if (input_format.pixel_format == FORMAT_RGB) {
-               glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, src);
+               format = GL_RGB;
        } else if (input_format.pixel_format == FORMAT_RGBA) {
-               glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, src);
+               format = GL_RGBA;
        } else {
                assert(false);
        }
+
+       glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, format, GL_UNSIGNED_BYTE, src);
        check_error();
        glUniform1i(glGetUniformLocation(glsl_program_num, "input_tex"), 0);