ofFbo and MRT rendering

Hi all.
How to use ofFbo for 1pass render into multiple color buffers (with GLSL) ?

System: Windows7
FrameFork: 0.7

My experiments:

  1. setup buffer:

ofFbo fb;
ofFbo::Settings set;

set.width = 320;
set.height = 200;
set.internalformat = GL_RGBA;
set.maxFilter = GL_LINEAR;
set.minFilter = GL_LINEAR;
set.numColorbuffers = [color=red]2;
set.numSamples = 1;
set.textureTarget = GL_TEXTURE_RECTANGLE;
set.useDepth = false;
set.useStencil = false;
set.wrapModeHorizontal = GL_CLAMP_TO_EDGE;
set.wrapModeVertical = GL_CLAMP_TO_EDGE;

fb.allocate(set);
[/color]

in LOG all is ok.
maxColorAttachments: 8
maxDrawBuffers: 8
OF: OF_LOG_NOTICE: FRAMEBUFFER_COMPLETE - OK

  1. Render to FBO:

fb.begin();

[color=red] GLenum db[2] = {GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1};
glDrawBuffers(2,db);

sh.begin(); // shader
Quad1(); // simple quad -1…1
sh.end();

fb.end();
[/color]
3) Shader variants:
vertex shader - just translate simple quad to fill viewport

#version 130
in vec4 Position;
void main() {
gl_Position = Position;
}
fragment shaders:

#version 110
void main(){
gl_FragData[0] = vec4(1,0,0,1);
gl_FragData[1] = vec4(0,1,0,1);
}

#version 130
out vec4 cRed;
out vec4 cGreen;
void main() {
cRed = vec4(1,0,0,1);
cGreen = vec4(0,1,0,1);
}

  • in c++ code:
    glBindFragDataLocation(sh.getProgram(),0,“cRed”);
    glBindFragDataLocation(sh.getProgram(),1,“cGreen”);
    sh.linkProgram();

#version 400
layout(location = 0) out vec4 cRed;
layout(location = 1) out vec4 cGreen;
void main() {
cRed = vec4(1,0,0,1);
cGreen = vec4(0,1,0,1);
}


  1. draw textures attached to FBO:
    fb.getTextureReference(0).draw(0,0);
    fb.getTextureReference(1).draw(0,400);

as result:
0 - filled by color (red or green if I change layout/bind location for cGreen variable to 0)
1 - always black.

How to store data into second texture too ? What am I doing wrong ?