input->output_node->bound_sampler_num = sampler;
glBindTexture(GL_TEXTURE_2D, output_textures[input]);
check_error();
- if (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);
+ if (phase->input_needs_mipmaps && generated_mipmaps->count(input) == 0) {
+ glGenerateMipmap(GL_TEXTURE_2D);
check_error();
+ generated_mipmaps->insert(input);
}
- 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();
+ setup_rtt_sampler(glsl_program_num, sampler, phase->effect_ids[input->output_node], phase->input_needs_mipmaps);
string texture_name = string("tex_") + phase->effect_ids[input->output_node];
glUniform1i(glGetUniformLocation(glsl_program_num, texture_name.c_str()), sampler);
CHECK(dither_effect->set_int("output_height", height));
}
} else {
- fbo = resource_pool->create_fbo(context, GL_RGBA16F, phase->output_width, phase->output_height);
+ fbo = resource_pool->create_fbo(context, output_textures[phase]);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
- check_error();
- glFramebufferTexture2D(
- GL_FRAMEBUFFER,
- GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D,
- output_textures[phase],
- 0);
- check_error();
- GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
- assert(status == GL_FRAMEBUFFER_COMPLETE);
glViewport(0, 0, phase->output_width, phase->output_height);
}
check_error();
}
+void EffectChain::setup_rtt_sampler(GLuint glsl_program_num, int sampler_num, const string &effect_id, bool use_mipmaps)
+{
+ glActiveTexture(GL_TEXTURE0 + sampler_num);
+ check_error();
+ if (use_mipmaps) {
+ 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_") + effect_id;
+ glUniform1i(glGetUniformLocation(glsl_program_num, texture_name.c_str()), sampler_num);
+ check_error();
+}
+
} // namespace movit