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