View Full Version : Stencil when rendering to FBO

09-12-2011, 03:34 PM
I'm trying to render the scene to a FBO with stencil buffers included. I've attached a depth stencil (d24s8) render buffer to the FBO and when I get the render buffers stencil size I do get 8.
But the stenciling just doesn't work.
It's supposed to clear the stencil buffer to 0x0 and then draw a triangle filled with 0x1. It works when I render normally but refuses to work when I render to the FBO. The FBO check returns that the FBO is complete.

I clear the stencil with
GL.ClearStencil(0x0); GL.Clear(ClearBufferMask.StencilBufferBit);

I don't know what else to try.

Is there some special way to write to the stencil buffer it I'm writing to a FBO?

09-12-2011, 03:36 PM
Maybe I should mention that the image renders normally. Just, non of it is hidden like it should be.

Ilian Dinev
09-12-2011, 04:09 PM
Did you make sure to attach the depth-stencil like this:


Also btw, some state is FBO-specific, so do the glEnable(GL_STENCIL) and such after you bind the FBO for drawing.

09-12-2011, 08:30 PM
Well I'm not using a texture for the stencil buffer. I'm using a render buffer. But I will try enabling stenciling after binding.

09-12-2011, 10:26 PM
Enabling stenciling after binding fixed it. Thank you.