- for (unsigned phase = 0; phase < phases.size(); ++phase) {
- // Find a texture for this phase.
- inform_input_sizes(phases[phase]);
- if (phase != phases.size() - 1) {
- find_output_size(phases[phase]);
-
- GLuint tex_num = resource_pool->create_2d_texture(GL_RGBA16F_ARB, phases[phase]->output_width, phases[phase]->output_height);
- output_textures.insert(make_pair(phases[phase], tex_num));
- }
-
- const GLuint glsl_program_num = phases[phase]->glsl_program_num;
- check_error();
- glUseProgram(glsl_program_num);
- check_error();
-
- // Set up RTT inputs for this phase.
- for (unsigned sampler = 0; sampler < phases[phase]->inputs.size(); ++sampler) {
- glActiveTexture(GL_TEXTURE0 + sampler);
- Phase *input = phases[phase]->inputs[sampler];
- input->output_node->bound_sampler_num = sampler;
- glBindTexture(GL_TEXTURE_2D, output_textures[input]);
- 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->output_node];
- glUniform1i(glGetUniformLocation(glsl_program_num, texture_name.c_str()), sampler);
- check_error();
- }