View Full Version : stencil-Buffer or not stencil-Buffer?

11-09-2001, 01:46 AM
I'm trying to draw in two seperate areas:
in one area should be drawn a static picture, and in the other area should be drawn a changin scene. Just like in a flight-simulator, where you can see the cockpit as a static picture and through the front-window you see the world moving.
My question is, how can I access this best.

I already heard of several ways to do this, but I'm not sure if I got it right, so I will describe them:
One way is to use the stencil-test. I could write my static picture into the StencilBuffer and instead of clearing the ColorBuffer, I would copy a black quad to the screen, to prevent that the static picture is erased.
Another way should be drawing the moving scene first, then clearing the DepthBuffer and then dawing the static picture (it should now be placed before the moving scene).

Now, I'd like to know what's the best way doing this. Or is there a better way? I thought I'd better ask before spending my time on doing sth. wrong.


[This message has been edited by aBeginner (edited 11-09-2001).]

11-09-2001, 03:30 AM
If your cockpit view is rectangular, I suggest you use glViewport/glScissors instead.

You split your window into two parts, I call them scene and cockpit.

Set glViewport and glScissors to cover the scene part of your window. Clear and draw the scene as usual.
If the cockpit view needs to be updated, set glViewport and glScissors to cover the cockpit part of your window. Clear the viewport and draw the cockpit as usual.

Using glScissors you can limit the area of glClear, so it doesn't clear the entire window.