+
+ // 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, frag_shader_outputs);
+ GLint position_attribute_index = glGetAttribLocation(phase->glsl_program_num, "position");
+ GLint texcoord_attribute_index = glGetAttribLocation(phase->glsl_program_num, "texcoord");
+ if (position_attribute_index != -1) {
+ phase->attribute_indexes.insert(position_attribute_index);
+ }
+ if (texcoord_attribute_index != -1) {
+ phase->attribute_indexes.insert(texcoord_attribute_index);
+ }