- // If we have more than one phase, we need intermediate render-to-texture.
- // Construct an FBO, and then as many textures as we need.
- // We choose the simplest option of having one texture per output,
- // since otherwise this turns into an (albeit simple)
- // register allocation problem.
- if (phases.size() > 1) {
- glGenFramebuffers(1, &fbo);
-
- for (unsigned i = 0; i < phases.size() - 1; ++i) {
- inform_input_sizes(phases[i]);
- find_output_size(phases[i]);
-
- Node *output_node = phases[i]->effects.back();
- glGenTextures(1, &output_node->output_texture);
- check_error();
- glBindTexture(GL_TEXTURE_2D, output_node->output_texture);
- check_error();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- check_error();
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- check_error();
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, phases[i]->output_width, phases[i]->output_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- check_error();
-
- output_node->output_texture_width = phases[i]->output_width;
- output_node->output_texture_height = phases[i]->output_height;
- }
- inform_input_sizes(phases.back());
- }
-
- for (unsigned i = 0; i < inputs.size(); ++i) {
- inputs[i]->finalize();
- }
-