View Full Version : How to clear stencil buffer after stencil test?

06-13-2003, 08:10 AM

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


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.

06-13-2003, 01:23 PM
its glClear(GL_STENCIL_BUFFER_BIT); are you aware of that. It should have given you a compile error though

[This message has been edited by mdog1234 (edited 06-13-2003).]

06-13-2003, 05:14 PM
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.

06-14-2003, 05:02 AM
Buffer clears are required to take scissoring and masking into account.

Before clearing the stencil, try inserting

and see if this helps.

06-14-2003, 07:54 AM
Thanks so much, zeckensack, I appreciate your help. It works.

06-14-2003, 08:04 AM
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.

again, thanks very much