I am currently working with the Stencil buffer and I encountered a problem. Maybe someone could give me a hint. Here’s the problem :
I have a binary image that I use as a mask for the stencil buffer ( written there with glDrawPixels ). Then I draw some object with these settings :
glStencilFunc (GL_EQUAL, 1, 1);
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
Works fine. The object gets drawn only where my stencil buffer values are 1.
However, now I would like that after my object is drawn, the pixels where it got drawn to be switched to 0 in the stencil buffer. From what I read about glStencilOp, I thought the following would work :
glStencilFunc (GL_EQUAL, 1, 1);
glStencilOp (GL_KEEP, GL_KEEP, GL_ZERO);
I thought that my stencil buffer values would be switched to 0 when the stencil test + depth test succeeds (which is when my object actually gets drawn), but all I can get is a very werid behavior. Like only some “lines” of my object gets drawn.
Anyone has an idea or a hint for me ?
Thanks