glDepthMask(GL_FALSE);
check_error();
+ // Generate a VAO. All the phases should have exactly the same vertex attributes,
+ // so it's safe to reuse this.
+ float vertices[] = {
+ 0.0f, 2.0f,
+ 0.0f, 0.0f,
+ 2.0f, 0.0f
+ };
+
+ GLuint vao;
+ glGenVertexArrays(1, &vao);
+ check_error();
+ glBindVertexArray(vao);
+ check_error();
+
+ GLuint position_vbo = fill_vertex_attribute(phases[0]->glsl_program_num, "position", 2, GL_FLOAT, sizeof(vertices), vertices);
+ GLuint texcoord_vbo = fill_vertex_attribute(phases[0]->glsl_program_num, "texcoord", 2, GL_FLOAT, sizeof(vertices), vertices); // Same as vertices.
+
set<Phase *> generated_mipmaps;
// We choose the simplest option of having one texture per output,
glUseProgram(0);
check_error();
+ cleanup_vertex_attribute(phases[0]->glsl_program_num, "position", position_vbo);
+ cleanup_vertex_attribute(phases[0]->glsl_program_num, "texcoord", texcoord_vbo);
+
+ glDeleteVertexArrays(1, &vao);
+ check_error();
+
if (do_phase_timing) {
// Get back the timer queries.
for (unsigned phase_num = 0; phase_num < phases.size(); ++phase_num) {
// from there.
setup_uniforms(phase);
- // Now draw!
- float vertices[] = {
- 0.0f, 2.0f,
- 0.0f, 0.0f,
- 2.0f, 0.0f
- };
-
- GLuint vao;
- glGenVertexArrays(1, &vao);
- check_error();
- glBindVertexArray(vao);
- check_error();
-
- 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_TRIANGLES, 0, 3);
check_error();
- cleanup_vertex_attribute(glsl_program_num, "position", position_vbo);
- cleanup_vertex_attribute(glsl_program_num, "texcoord", texcoord_vbo);
-
glUseProgram(0);
check_error();
if (!last_phase) {
resource_pool->release_fbo(fbo);
}
-
- glDeleteVertexArrays(1, &vao);
- check_error();
}
void EffectChain::setup_uniforms(Phase *phase)