Hi All.
I want to bind multiple texture attachments. It does work when I bind multiple textures, but just not the texture attachments. I checked the texture attachments and they draw if I bind just one, but binding multiple of them only draws one.
This is my framebuffer and texture attachment code:
glGenFramebuffers(1, fbo);
glGenTextures(1, tao);
glBindFramebuffer(GL_FRAMEBUFFER, *fbo);
glBindTexture(GL_TEXTURE_2D, *tao);
glTexImage2D(GL_TEXTURE_2D, 0, (GLint)GL_RGBA32F,
width,
height,
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLint)GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (GLint)GL_MIRRORED_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (GLint)GL_MIRRORED_REPEAT);
glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, *tao, 0);
glBindTexture(GL_TEXTURE_2D, 0); // unbind
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
std::cout << "Framebuffer bad." << std::endl;
}
And this is the uniform & drawing code:
glUseProgram(blend_program); glCheckError();
GLuint tex0 = glGetUniformLocation(blend_program, "tex0");
glUniform1i(tex0, 0);
GLuint tex1 = glGetUniformLocation(blend_program, "tex1");
glUniform1i(tex1, 1);
glActiveTexture(GL_TEXTURE0); glCheckError();
glBindTexture(GL_TEXTURE_2D, tao[0]); glCheckError();
glActiveTexture(GL_TEXTURE1); glCheckError();
glBindTexture(GL_TEXTURE_2D, tao[1]); glCheckError();
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glCheckError();
The code draws only the first texture attachment. However if I bound an actual texture (as opposed to a texture attachment) in GL_TEXTURE1, it draws both images.
This is being implemented in an after effects plugin. The exact same code works in a standalone app but not in AE, so I’m quite puzzled. Any info/hints would be appreciated. Thanks.