hi all,
Is it possible to do have a single FBO with different size color attachments like this ( I m trying to render to 8 downscaled color attachments. This setup code does not give me any errors though. For test I have written a simple fragment shader (given later) but the output does not produce the correct result I only see the color of the 0th attachment).
const int MAX_ATTACHMENTS=8;
glGenTextures(MAX_ATTACHMENTS, attachID);
glGenFramebuffers(1, &fboID);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboID);
int width = screen_width;
int height = screen_height;
for(int i = 0;i < MAX_ATTACHMENTS;i++) {
glBindTexture(GL_TEXTURE_2D, attachID[i]);
glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D , GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D , 0, GL_RGBA, width, height, 0, GL_RGBA, GL_FLOAT, NULL);
width = width >> 1;
height = height >> 1;
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0+i, GL_TEXTURE_2D, attachID[i], 0);
}
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status == GL_FRAMEBUFFER_COMPLETE_EXT ) {
printf("FBO setup succeeded.");
} else {
printf("Problem with FBO setup.");
}
and here is the fragment shader code
#version 130
void main() {
gl_FragData[0] = vec4(1,0,0,1);
gl_FragData[1] = vec4(0,1,0,1);
gl_FragData[2] = vec4(0,0,1,1);
gl_FragData[3] = vec4(1,1,0,1);
gl_FragData[4] = vec4(1,0,1,1);
gl_FragData[5] = vec4(0,1,1,1);
gl_FragData[6] = vec4(0.5,1,1,1);
gl_FragData[7] = vec4(0.5,1,0.5,1);
}