]> git.sesse.net Git - movit/blobdiff - effect_chain.cpp
Draw an oversized triangle instead of a quad.
[movit] / effect_chain.cpp
index d33cdaeb4a42e6aab680b62c684ccf8dbac2bf4e..048cc1e0dbe878b881449af0366aa19feb2217c3 100644 (file)
@@ -623,7 +623,8 @@ void EffectChain::inform_input_sizes(Phase *phase)
        // Now propagate from the inputs towards the end, and inform as we go.
        // The rules are simple:
        //
-       //   1. Don't touch effects that already have given sizes (ie., inputs).
+       //   1. Don't touch effects that already have given sizes (ie., inputs
+       //      or effects that change the output size).
        //   2. If all of your inputs have the same size, that will be your output size.
        //   3. Otherwise, your output size is 0x0.
        for (unsigned i = 0; i < phase->effects.size(); ++i) {
@@ -645,8 +646,16 @@ void EffectChain::inform_input_sizes(Phase *phase)
                                this_output_height = 0;
                        }
                }
-               node->output_width = this_output_width;
-               node->output_height = this_output_height;
+               if (node->effect->changes_output_size()) {
+                       // We cannot call get_output_size() before we've done inform_input_size()
+                       // on all inputs.
+                       unsigned real_width_ignored, real_height_ignored;
+                       node->effect->get_output_size(&real_width_ignored, &real_height_ignored,
+                                                     &node->output_width, &node->output_height);
+               } else {
+                       node->output_width = this_output_width;
+                       node->output_height = this_output_height;
+               }
        }
 }
 
@@ -1598,10 +1607,9 @@ void EffectChain::execute_phase(Phase *phase, bool last_phase, map<Phase *, GLui
 
        // Now draw!
        float vertices[] = {
-               0.0f, 1.0f,
+               0.0f, 2.0f,
                0.0f, 0.0f,
-               1.0f, 1.0f,
-               1.0f, 0.0f
+               2.0f, 0.0f
        };
 
        GLuint vao;
@@ -1613,7 +1621,7 @@ void EffectChain::execute_phase(Phase *phase, bool last_phase, map<Phase *, GLui
        GLuint position_vbo = fill_vertex_attribute(glsl_program_num, "position", 2, GL_FLOAT, sizeof(vertices), vertices);
        GLuint texcoord_vbo = fill_vertex_attribute(glsl_program_num, "texcoord", 2, GL_FLOAT, sizeof(vertices), vertices);  // Same as vertices.
 
-       glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+       glDrawArrays(GL_TRIANGLES, 0, 3);
        check_error();
 
        cleanup_vertex_attribute(glsl_program_num, "position", position_vbo);