Stencil buffer and clearing

I’m making a game interface and want to have a border around the 3D world that has buttons and stuff.

Currently I draw the border each frame, but I want to only update the border when it has changed in some way(Buttons pressed or sliders moved).

The 3D world changes alot and I want to be able to clear and redraw the world.

How can I clear the screen where the stencil buffer is equal to 1?

I don’t think you can, but what you can do is drawing where the stencil is 1, with glStencilFunc(). You should be able to do what you wanted to with that.

Use the Accumulation buffer.

Just write you menu bar onced. Then put it in the accumulation buffer (or any other buffer if you wish) and then just reload the accumulation buffer in color buffer every frame!. The coolest thing about that, is that you can disable depth buffer testing.