The following code sets up the stencil test to see if ref
is greater than the stored value in the stencil buffer, and if it is, it'll write ref
to the stencil buffer
unsigned int ref = 42;
glStencilFunc(GL_GREATER, ref, 0xFF);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
The problem is that while I do want to test the stencil buffer against ref
, I don't want to write ref
to it if it succeeds, I want to write a totally different value. The only option I've found is GL_INCR
which can take the place of GL_REPLACE
, but that's not very useful if the stencil buffer has a lot of stuff already written to it that can't be cleared out beforehand.
Is there a way to... say, test to see if 42 is greater than what's stored in the stencil buffer, and if it is, write 100 or something else to it?