I wrote some thing like below:
glClearStencil(0x0);
glEnable(GL_STENCIL_TEST);
glClear (GL_STENCIL_BUFFER_BIT);
glStencilFunc(GL_ALWAYS, 0x4, 0x4);
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
draw something…
glStencilFunc(GL_EQUAL, 0x4, 0x4);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
draw something …
glStencilFunc(GL_EQUAL, 0x5, 0x5);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
draw something …
during the second stencil operation, if the z buffer test pass, the value is supposed to be incremented by 1 that is 4+1=5, so that the third operation can function, but I found the value is 0x6 using debug, it seems the increment operation just shift the value one bit right so it is 6. can someone tell me how to increment it to be 5? thanks.