I use glut and in the display function, I clear the stencil buffer and draw some geometry with stencil test on. after that I want to clear the stencil buffer immediately. I use
glClearStencil(0X0);
glClear(Stencil_buffer_bit);
then I read the stencil buffer but it is same. I need to use stencil test multiple times during the display function.
How to clear it during display? so I can use it for next stencil test.
thanks for your reply, I am aware of that. I just want to show the idea, sorry I did not use the correct word.
I run the program and after I clear the stencil buffer, I read it into the main memory and check the value, it is still the same as the one before I clear it. I also try to use stencil test to clear it, it is still not working.
some information I want to add after I tested the program.
It seems that glStencilMask(~0) works, because I used this function when I do stencil test in the program, now I need to set it to ~0 to make clearing works.
scissor test seems have not effect on clearing buffer in my program.