• Advertisement
Sign in to follow this  

Frame Buffer Object EXT and Stencil Shadows

This topic is 4495 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I need help! I can't get the stencil buffer to work with the frame buffer object extension... BLACK SCREEN! I have a GeForce 6150 and my code looks like this: crBool crFrameBuffer::Create(crInt32 iWidth, crInt32 iHight) { crGenFramebuffersEXT(1, &m_uiFrameBuffer); crGenRenderbuffersEXT(1, &m_uiDepthBuffer); crGenRenderbuffersEXT(1, &m_uiStencilBuffer); crBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_uiDepthBuffer); crRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, iWidth, iHight); crBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_uiStencilBuffer); crRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_STENCIL_INDEX, iWidth, iHight); glGenTextures(1, &m_uiDynamicTextureID); glBindTexture(GL_TEXTURE_2D, m_uiDynamicTextureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, iWidth, iHight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); return (crCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) == GL_FRAMEBUFFER_COMPLETE_EXT); } //---------------------------------------------------------------- void crFrameBuffer::Attach() { crBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_uiFrameBuffer); crFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_uiDynamicTextureID, 0); crFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_uiDepthBuffer); crFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_uiStencilBuffer); } //---------------------------------------------------------------- void crFrameBuffer::Detach() { crBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } WHATS WRONG???

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I ran in that problem about a month ago. At that time it just wasn't possible. This was stated by this forum as well as the forum on opengl.org. Hopefully this might change soon.

If you really need stenciling try this:
1. render the stencil part to a texture (just black and white)
2. render the scene to a texture
3. combine the two textures
This might not be the best method but still it works which was good enough for me :)

@golgoth: PSQ_Goblin passes NULL because he wants to render to texture, which in fact creates the data.

Hope this helps,
f_lacour

Share this post


Link to post
Share on other sites
You can get it to work. first, get a ForceWare Driver >= 81.85.
then , add these lines to your headers:

#define GL_DEPTH_STENCIL_EXT 0x84F9
#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
#define GL_DEPTH24_STENCIL8_EXT 0x88F0
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1



Then, create ONLY ONE render buffer.
Then, Do the following:

glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthStencilRT);
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, Width, Height);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, DepthStencilRT);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
GL_RENDERBUFFER_EXT, DepthStencilRT);



Yes, attach same render buffer twice, once as depth and once as stencil.
The above code works perfectly on my 6600 Go and 7800 GTX.
Lemme know if you run into any more trouble.

Share this post


Link to post
Share on other sites
One more thing. you should attach render buffers only once at initialization. your Attach function should just do BindFrameBuffer().

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement