Frame Buffer Object EXT and Stencil Shadows

Started by
5 comments, last by _the_phantom_ 18 years, 3 months ago
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???
Advertisement
At first sight, i think you need to alocate image data instead of passing NULL in glTexImage2D!
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
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.
One more thing. you should attach render buffers only once at initialization. your Attach function should just do BindFrameBuffer().
Thank you so mutch! It works nicely now...

But is the defines really nessesary??? If so why. Is it a bug?
the defines are part of the new extension needed to make a depth-stencil texture

This topic is closed to new replies.

Advertisement