PDA

View Full Version : Multiple FB's in FBO



Nithos
04-20-2005, 10:29 AM
Has anybody got multiple framebuffers working in FBO, i got multiple textures to work fine, and multiple FB's compiles and runs but when i display them it only displays the last rendered FB

not sure what i'm doing wrong here is my multiple FB setup


glGenFramebuffersEXT(numBuffers, fb);
//initialize frame buffers
for(int i=0;i<numBuffers;i++)
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[i]);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,GL_CO LOR_ATTACHMENT0_EXT,GL_TEXTURE_2D,color_tex[i], 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth_rb);

CHECK_FRAMEBUFFER_STATUS();
}

void RenderTarget::BindAsRenderTarget(int i)
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb[i]);
}
And using it

for(int i=0; i<4; i++)
{
//Bind rendertarget for rendering
rt->BindAsRenderTarget(i);
//Clear rendertarget buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//render
switch(i)
{
case 0:
glColor3f(1.0f,1.0f,0.0f);
break;
case 1:
glColor3f(1.0f,0.0f,0.0f);
break;
case 2:
glColor3f(0.0f,1.0f,0.0f);
break;
case 3:
glColor3f(1.0f,0.5f,0.5f);
break;
}
glRotatef(a,0,1,0);
glutSolidTeapot(1);
a += 1.0;
//disableShaders();
}

//glColor3f(1.0f,0.5f,1.0f);
//Get our normal framebuffer back for rendering
rt->UnBindAsRenderTarget(); What am I doing wrong?

Nithos
04-21-2005, 08:22 AM
Nevermind found what I was doing wrong.

Java Cool Dude
04-21-2005, 08:35 AM
I remember setting up an FBO for every face of a cubemap texture for a total of 6 and having it work like a charm, hmmm what were you doing wrong?

Nithos
04-21-2005, 09:31 AM
Two things, the setup was correct, but I was passing the wrong number for the numBuffers variable (for debuggin i was setting it to 1 which is NOT multiple :) ) and second I wasnt pushing the matricies in the correct position so that each consecutive frame buffer was built ontop of the previous ones etc...

Nothing major just a couple stupid mistakes ;)

Henry Jones
06-29-2005, 12:17 AM
hi

i tried to create two fbos
if try to display the texture of the first one created, i only see the texture of the second fbo

creating a fbo:

bool FBOTest::createFBO()
{
tglGenFramebuffersEXT( 1, &amp;m_unFBO);

glGenTextures( 1, &amp;m_unTexture);

tglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_unFBO);

glBindTexture( E_FBO_TARGET, m_unTexture);

glTexImage2D( E_FBO_TARGET,
0,
GL_RGBA8,
m_unHres,
m_unVres,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
0);

tglFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT,
E_ATTACH_TARGET[0],
E_FBO_TARGET,
m_unTexture,
0);

glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

if ( !tglIsFramebufferEXT( m_unFBO))
{
checkFBO();

return false;
}

tglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);

checkAll();

return checkFBO( "FBOTest::createFBO");
}with :
E_FBO_TARGET = GL_TEXTURE_RECTANGLE_NV
E_ATTACH_TARGET = GL_COLOR_ATTACHMENT0_EXT

binding fbo:

bool FBOTest::bindFBO()
{
tglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_unFBO);

glClear( GL_COLOR_BUFFER_BIT);

return checkFBO( "FBOTest::bindFBO");
}unbinding FBO:

bool FBOTest::unbindFBO()
{
tglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);

return checkFBO( "FBOTest::unbindFBO");
}displaying FBO:

tglBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0);

glBindTexture( SimpleFBO::E_FBO_TARGET,unTexture);main loop:

if ( kTestFBO[0].bindFBO())
{
kDisplay.drawOverlay( 0);

kTestFBO[0].unbindFBO();
}

if ( kTestFBO[1].bindFBO())
{
kDisplay.drawOverlay( 1);

kTestFBO[1].unbindFBO();
}

while ( true)
{
kDisplay.displayFBO( kTestFBO[unFBO % 2].texture());

++unFBO;

kDisplay.swapBuffers();

// ZZZ
}So, the only thing i am seeing is
kDisplay.drawOverlay( 1);
what am i missing / doing wrong ...???

Second thing is, that if i change E_FBO_TARGET to GL_TEXTURE_2D, i get GL_FRAMEBUFFER_UNSUPPORTED_EXT

os is SuSE 8.2
glxinfo :
OpenGL renderer string: GeForce 6800 Ultra/AGP/SSE2
OpenGL version string: 2.0.0 NVIDIA 76.64

Thanks in advance

PfhorSlayer
06-29-2005, 11:08 AM
Originally posted by Java Cool Dude:
I remember setting up an FBO for every face of a cubemap texture for a total of 6 and having it work like a charm, hmmm what were you doing wrong?I found that my drivers give me 4 color buffers, so I was able to bind an entire cube map using only 2 FBOs and glDrawBuffer(). You might want to check that out if you want some more speed (only two FBO switches to fill the entire cube map!)