Hi everyone,
I have a question regarding FBO usage and Draw/Read buffer changes:
- I have one pre render camera using FBO and with 2 textures attached (to
COLOR_BUFFER0 and COLOR_BUFFER1)
- Under that camera I would like to add multiple screen aligned quads that
would use the attached textures this way: (call them tex0 and tex1):
- quad0 would using the tex0 as input and draw on tex1
- quad1 would then use tex1 as input and draw on tex0
- quad2 would using the tex0 as input and draw on tex1
- quad3 would then use tex1 as input and draw on tex0
- etc.
This is possible in pure OpenGL using something like that:
* glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fftFbo2);
glUseProgram(fftx->program);
glUniform1i(glGetUniformLocation(fftx->program, "nLayers"), choppy ? 5 :
3);
for (int i = 0; i < PASSES; ++i) {
glUniform1f(glGetUniformLocation(fftx->program, "pass"), float(i +
0.5) / PASSES);
if (i%2 == 0) {
glUniform1i(glGetUniformLocation(fftx->program, "imgSampler"),
FFT_A_UNIT);
glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
} else {
glUniform1i(glGetUniformLocation(fftx->program, "imgSampler"),
FFT_B_UNIT);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
}
drawQuad();
}
glUseProgram(ffty->program);
glUniform1i(glGetUniformLocation(ffty->program, "nLayers"), choppy ? 5 :
3);
for (int i = PASSES; i < 2 * PASSES; ++i) {
glUniform1f(glGetUniformLocation(ffty->program, "pass"), float(i -
PASSES + 0.5) / PASSES);
if (i%2 == 0) {
glUniform1i(glGetUniformLocation(ffty->program, "imgSampler"),
FFT_A_UNIT);
glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
} else {
glUniform1i(glGetUniformLocation(ffty->program, "imgSampler"),
FFT_B_UNIT);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
}
drawQuad();
}
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);*
.. but I can't figure out how to do something equivalent to the internal
calls to glDrawBuffer in the previous snippet when I have a single camera.
(as calling setDrawBuffer() is done once and for all before rendering
anything... Any idea what could be worth trying here ?
Cheers,
Manu.
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org