glDrawBuffers and GL_COLOR_ATTACHMENTi

2014/12/21 19:42

Just to clear some stuff up for myself…

//in the shader if we had...
layout(location = 0) out vec4 mainColor[4];
//and in the callling program we had
GLenum bufs[] = {GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT5, GL_NONE, GL_COLOR_ATTACHMENT0};
glDrawBuffers(4,bufs);
//then
//mainColor[0] at (location = 0) maps to GL_COLOR_ATTACHMENT1
//mainColor[1] at (location = 1) maps to GL_COLOR_ATTACHMENT5
//mainColor[2] at (location = 2) ouput to this is disguarded
//mainColor[3] at (location = 3) maps to GL_COLOR_ATTACHMENT0

Guaranteed at least 8 color attachments in GL4.2. See

http://www.opengl.org/sdk/docs/man4/xhtml/glDrawBuffers.xml
http://www.opengl.org/wiki/Framebuffer_Object#Multiple_Render_Targets

also, when calling glBlitFramebuffer between two MRT FBOs you seem to be limited to copying from between GL_COLOR_ATTACHMENT0 and GL_COLOR_ATTACHMENT0 on both sides (when blitting GL_COLOR_BUFFER_BIT)