Stenciling and multiple buffer "ands"

Stenciling and multiple buffer "ands"

Post by Scott Moor » Thu, 08 Sep 2005 09:29:35


Hi,

I am porting an existing application that does the same effect as
stenciling by setting up a pattern in an non-displayed buffer,
then "and"ing the pattern to be stenciled with this buffer
(In Windows terminolgy, we ROP the pattern to be displayed with the
pattern buffer in a bitmap DC, then move that to the display DC).

This same technique would appear to work with OpenGL, but I note
that OpenGL also offers stencil buffers. What does stenciling offer
that the current technique we are using does not ? Is this about
using less display memory ?

Thank you.
 
 
 

Stenciling and multiple buffer "ands"

Post by fungu » Thu, 08 Sep 2005 12:52:10


A common technique... :-)



I can think of a couple of ways to do it in OpenGL.
One is to use stencilling, another is to put your
pattern in a texture and use glAlphaFunc().


Stencilling can do much more than a simple mask effect,
though that's probably not useful to you.

Normally stencil doesn't use any extra memory because
it's stored in the same place as the OpenGL depth buffer.

--
<\___/>
/ O O \
\_____/ FTB. For email, remove my socks.

In science it often happens that scientists say, 'You know
that's a really good argument; my position is mistaken,'
and then they actually change their minds and you never
hear that old view from them again. They really do it.
It doesn't happen as often as it should, because scientists
are human and change is sometimes painful. But it happens
every day. I cannot recall the last time something like
that happened in politics or religion.

- Carl Sagan, 1987 CSICOP keynote address