PDA

View Full Version : FBO doubts



kil4h
05-13-2010, 09:03 AM
Hi all,

I am facing 3 problems while using FBOs, that I hope you guys can help me with.

The first part of my doubts is about some knowledge I lack:
If blitFrameBuffer extension isn't available, how do you copy a multisampled image from a FBO(color is done with a renderbuffer) to the window-system-buffer GL_BACK buffer? Also, when I try to use blitFrameBuffer with different source and destination size values, the function fails with INVALID_OPERATION, but when I checked GL_EXT_framebuffer_blit I found no reason for this to happen (I could have missed the explanation thought). My guess is that trying to blit 2 DEPTH renderbuffer with different sizes provokes a failure, but that doesn't seem to behave like it should.GL_NEAREST interpolation is present and is the "recommended" one by the extension.
NOTE: both FBOs use the same internal format. Also I am under 196.21 NVIDIA drivers on a XP SP3 system.

The second part of my question is about an error I get but which I completely fail to see a reason why.
I am creating a FBO object in order to simplify FBO creation,attach and detach operations and so on. Reinventing the wheel as always so I can have a deeper understanding on what is going. Yet I completely fail to see what happens with the code as simple as this one.


// INIT FBO OBJECT FUNC
glGenFramebuffers( 1, &m_fbo );
glBindFramebuffer( GL_FRAMEBUFFER_EXT, m_fbo );
switch( type ){
case FBO_SM:
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texture[0], 0 );

glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);

break;
[...]
if( GL_FRAMEBUFFER_COMPLETE_EXT != (m_error = glCheckFramebufferStatus( GL_FRAMEBUFFER_EXT )) ) {
glBindFramebuffer( GL_FRAMEBUFFER_EXT, 0 );
return false;
}

glBindFramebuffer( GL_FRAMEBUFFER_EXT, 0 );

// BIND FUNC
void CFBO::bind() {
glBindFramebuffer( GL_FRAMEBUFFER_EXT, m_fbo );
glPushAttrib(GL_VIEWPORT_BIT);
glViewport(0,0,m_width, m_height);
}

// UNBIND FUNC
void CFBO::unBind() {
glPopAttrib();
glBindFramebuffer( GL_FRAMEBUFFER_EXT, 0 );
}

// TEXTURE CREATION CODE
glGenTextures(1, &texture[0]);
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 512, 512, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0);
glBindTexture(GL_TEXTURE_2D, 0);



When I try to render the depth texture into a quad, it fails (garbage is printed). Anyone has a hint on what is going on?
NOTE: glGetError() and glCheckFramebufferStatus() return correct values.

skynet
05-13-2010, 12:03 PM
1) EXT_framebuffer_multisample never comes without EXT_framebuffer_blit

2)EXT_framebuffer_blit says:

The error INVALID_OPERATION is generated if BlitFramebufferEXT is
called and <mask> includes DEPTH_BUFFER_BIT or STENCIL_BUFFER_BIT
and <filter> is not NEAREST.

The error INVALID_OPERATION is generated if BlitFramebufferEXT is
called and <mask> includes DEPTH_BUFFER_BIT or STENCIL_BUFFER_BIT
and the source and destination depth or stencil buffer formats do
not match.

So, it seems to be allowed to do a stretching/shrinking blit with depthbuffers involved as long as a) filter is GL_NEAREST b) depth/stencil formats match and c) no multisampled buffers are involved