X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=effect_chain.cpp;h=6f53008c72eb43c0df26079d1ba8c1f95d9d57b0;hb=b618b34070d23b6da35c77f004678d8a9e55575b;hp=19c485c32aea33acb2d6fc8fd57cf848288380f5;hpb=0c1fab7813e12580bed0852d9e57b0a3f2768d83;p=movit diff --git a/effect_chain.cpp b/effect_chain.cpp index 19c485c..6f53008 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -64,7 +64,7 @@ void EffectChain::normalize_to_linear_gamma() } else { GammaExpansionEffect *gamma_conversion = new GammaExpansionEffect(); gamma_conversion->set_int("source_curve", current_gamma_curve); - effects.push_back(gamma_conversion); + gamma_conversion->add_self_to_effect_chain(&effects); } current_gamma_curve = GAMMA_LINEAR; } @@ -75,7 +75,7 @@ void EffectChain::normalize_to_srgb() ColorSpaceConversionEffect *colorspace_conversion = new ColorSpaceConversionEffect(); colorspace_conversion->set_int("source_space", current_color_space); colorspace_conversion->set_int("destination_space", COLORSPACE_sRGB); - effects.push_back(colorspace_conversion); + colorspace_conversion->add_self_to_effect_chain(&effects); current_color_space = COLORSPACE_sRGB; } @@ -91,7 +91,7 @@ Effect *EffectChain::add_effect(EffectId effect_id) normalize_to_srgb(); } - effects.push_back(effect); + effect->add_self_to_effect_chain(&effects); return effect; } @@ -221,6 +221,7 @@ void EffectChain::finalize() glGenTextures(num_textures, temp_textures); unsigned char *empty = new unsigned char[width * height * 4]; + memset(empty, 0, width * height * 4); for (unsigned i = 0; i < num_textures; ++i) { glBindTexture(GL_TEXTURE_2D, temp_textures[i]); check_error(); @@ -266,6 +267,7 @@ void EffectChain::finalize() void *mapped_pbo = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, GL_WRITE_ONLY); memset(mapped_pbo, 0, width * height * bytes_per_pixel); glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB); + check_error(); glGenTextures(1, &source_image_num); check_error(); @@ -329,6 +331,7 @@ void EffectChain::render_to_screen(unsigned char *src) for (unsigned phase = 0; phase < phases.size(); ++phase) { // Set up inputs and outputs for this phase. + glActiveTexture(GL_TEXTURE0); if (phase == 0) { // First phase reads from the input texture (which is already bound). } else { @@ -356,6 +359,7 @@ void EffectChain::render_to_screen(unsigned char *src) GL_TEXTURE_2D, temp_textures[phase % 2], 0); + check_error(); } // We have baked an upside-down transform into the quad coordinates,