stencil???

I am really confused with the use of the stencil buffer. I was trying to modify the stencil example in the red book to just draw
a square in the center of the screen and then try to see what would happen if I then tried to draw in there again. I got some
weird results that I was not able to interpret. Can someone please help me with this. I would appreciate a simple example. I was trying to define a square stencil area in the middle of the screen and then see what happens when I drew other objects that
overlaped it partially. I guess I don’t understand exactly what glStencilFunc and glStencilOp are doing. I don’t understand
what the argument mask means in glStencilFunc.

I posted a simple explanation in the beginner forum.