X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=effect_chain.cpp;h=5c4b52246b255738b2c8b764c13c12547e215ef1;hb=6bf496a34a84fb14b1b3b6debfd42ba36568b879;hp=4c2df4c2de6dbce9563c4f34700891b113acdc7e;hpb=06ba8d86c019208682d8883dc7187df37b027814;p=movit diff --git a/effect_chain.cpp b/effect_chain.cpp index 4c2df4c..5c4b522 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -39,6 +39,7 @@ EffectChain::EffectChain(float aspect_nom, float aspect_denom, ResourcePool *res aspect_denom(aspect_denom), dither_effect(NULL), num_dither_bits(0), + output_origin(OUTPUT_ORIGIN_BOTTOM_LEFT), finalized(false), resource_pool(resource_pool), do_phase_timing(false) { @@ -207,7 +208,7 @@ Effect *EffectChain::add_effect(Effect *effect, const vector &inputs) return effect; } -// GLSL pre-1.30 doesn't support token pasting. Replace PREFIX(x) with _x. +// ESSL doesn't support token pasting. Replace PREFIX(x) with _x. string replace_prefix(const string &text, const string &prefix) { string output; @@ -407,6 +408,17 @@ void EffectChain::compile_glsl_program(Phase *phase) frag_shader = frag_shader_header + frag_shader_uniforms + frag_shader; string vert_shader = read_version_dependent_file("vs", "vert"); + + // If we're the last phase and need to flip the picture to compensate for + // the origin, tell the vertex shader so. + if (phase->output_node->outgoing_links.empty() && output_origin == OUTPUT_ORIGIN_TOP_LEFT) { + const string needle = "#define FLIP_ORIGIN 0"; + size_t pos = vert_shader.find(needle); + assert(pos != string::npos); + + vert_shader[pos + needle.size() - 1] = '1'; + } + phase->glsl_program_num = resource_pool->compile_glsl_program(vert_shader, frag_shader); // Collect the resulting location numbers for each uniform.