- // Set up RTT inputs for this phase.
- for (unsigned sampler = 0; sampler < phases[phase]->inputs.size(); ++sampler) {
- glActiveTexture(GL_TEXTURE0 + sampler);
- Node *input = phases[phase]->inputs[sampler];
- input->bound_sampler_num = sampler;
- glBindTexture(GL_TEXTURE_2D, output_textures[input->phase]);
- check_error();
- if (phases[phase]->input_needs_mipmaps) {
- if (generated_mipmaps.count(input) == 0) {
- glGenerateMipmap(GL_TEXTURE_2D);
- check_error();
- generated_mipmaps.insert(input);
- }
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
- check_error();
- } else {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- 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();
-
- string texture_name = string("tex_") + phases[phase]->effect_ids[input];
- glUniform1i(glGetUniformLocation(glsl_program_num, texture_name.c_str()), sampler);
- check_error();
- }
-
- // And now the output.
- if (phase == phases.size() - 1) {