PDA

View Full Version : FBO Stencil Buffer = GL FRAMEBUFFER INCOMPLETE ATTACHMENT EXT



Golgoth
03-30-2007, 06:40 PM
Hi all!

Im trying to get FBO Stencil Buffer to simply compile successfully… but whatever I try I m always getting GL FRAMEBUFFER INCOMPLETE ATTACHMENT EXT… I ve posted the code below. I hope this is a simple one!

First, I bind a frame buffer to a texture. Successful!
Second, I bind a depth buffer to a texture. Successful!
Third, I bind a stencil buffer… failed at glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_StencilBufferID);!



void PBuffer::Set()
{
UInt &l_frameBufferId = m_FrameTexture->GetBufferId();
if (l_frameBufferId == 0)
{
AX6_RENDERER()->GenerateTexture(m_FrameTexture);
AX6_RENDERER()->DisableTexture(m_FrameTexture);
glGenFramebuffersEXT(1, &l_frameBufferId);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, l_frameBufferId);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, m_FrameTexture->GetDimension(), m_FrameTexture->GetId(), 0);
AX6_OPENGL_CHECK_FRAME_BUFFER_STATUS();
}
else
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, l_frameBufferId);
glClear(GL_COLOR_BUFFER_BIT);
}

UInt &l_depthBufferId = m_DepthTexture->GetBufferId();
if (l_depthBufferId == 0)
{
AX6_RENDERER()->GenerateTexture(m_DepthTexture);
AX6_RENDERER()->DisableTexture(m_DepthTexture);
glGenRenderbuffersEXT(1, &l_depthBufferId);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, l_depthBufferId);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, m_Width, m_Height);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, m_DepthTexture->GetDimension(), m_DepthTexture->GetId(), 0);
AX6_OPENGL_CHECK_FRAME_BUFFER_STATUS();
}
else
{
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, l_depthBufferId);
glClear(GL_DEPTH_BUFFER_BIT);
}

if(m_StencilBufferID == 0)
{
glGenRenderbuffersEXT(1, &m_StencilBufferID);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_StencilBufferID);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX8_EXT, m_Width, m_Height);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_StencilBufferID);
AX6_OPENGL_CHECK_FRAME_BUFFER_STATUS();
}
else
{
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_StencilBufferID);
glClear(GL_STENCIL_BUFFER_BIT);
}
}

void PBuffer::Unset()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, 0);
} I ve also tried GL_EXT_packed_depth_stencil, and did exacly (afaict) what the spec propose with the same result: GL FRAMEBUFFER INCOMPLETE ATTACHMENT EXT, anyone can help me clear this out?

thx

Korval
03-30-2007, 07:07 PM
What hardware are you using? And what driver version?

Golgoth
03-30-2007, 07:18 PM
hi korval, Gforce 7800 with driver version 93.71 (latest). the code looks good right? I ve been scratching my head on this for a while. I cant figure it out.

I also use SDL set to:
frame_buffer_size="32"
depth_buffer_size="24"
stencil_buffer_size="8"

and GLEW version "1.3.6"

zeoverlord
04-01-2007, 07:00 AM
I had this problem to, i don't know how it works on ATI cards but on nvidia cards you have to bind depth and stencil together using GL_DEPTH24_STENCIL8_EXT.

it goes something like this.

glGenRenderbuffersEXT(1, &depth);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depth);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,GL_DE PTH24_STENCIL8_EXT, x, y);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depth);

Golgoth
04-01-2007, 09:30 AM
Got it!

thx