From: Aron Bartle (abartle++at++vrco.com)
Date: 06/20/2000 11:59:13
Hello,
I suspect most here have done something at least this advanced using
Performer+OpenGL. The OGL programming guide 1.1 has a good example for
using the stencil test on p.387, but I lack knowledge on how to
integrate it into a performer app.
___
I'm trying to mask everything outside of a rectangular area for some
arbitrary node in the scene graph. I understand (I think) how the
stencil buffer makes masking work.
What I don't understand is what coordinates I should use for drawing the
rectangle in the stencil buffer!? I know the coordinates of the
rectangle in the local space for the node, but how should I transform
them to use in the stencil buffer?
I think I must be missing something fundamental. I thought the OGL
matrix stack was maintained by performer, so in a callback I should be
able to just use the coordinates local to that node. Do I need to
transform for DCS's above the node in the performer scene graph? For the
projection? Does someone have an example that does this?
Or, is there an easier way to do this type of masking using straight
performer? Maybe using pfLayer in stencil mode?
Thanks for any help! Below are the pre & post DRAW callbacks I'm using.
-Aron
___
// pre draw callback
int preDraw( pfTraverser* trav, void* data )
{
maskArea* m = static_cast<maskArea*>( data );
glClearStencil(0x0);
glClear(GL_STENCIL_BUFFER_BIT);
glEnable(GL_STENCIL_TEST);
// draw rectangle in stencil buffer
glMatrixMode( GL_MODELVIEW );
glStencilFunc( GL_ALWAYS, 0x1, 0x1 );
glStencilOp( GL_REPLACE, GL_REPLACE, GL_REPLACE );
glBegin( GL_QUADS );
glVertex3f( m->xMin, m->yMin, m->zVal );
glVertex3f( m->xMin, m->yMax, m->zVal );
glVertex3f( m->xMax, m->yMax, m->zVal );
glVertex3f( m->xMax, m->yMin, m->zVal );
glEnd();
// prepare stencil test for drawing
glStencilFunc( GL_EQUAL, 0x1, 0x1 );
glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP );
}
int postDraw(...)
{
glDisable( GL_STENCIL_TEST );
}
-- Aron Bartle, Software Architect abartle++at++vrco.com 757.858.2800
This archive was generated by hypermail 2b29 : Tue Jun 20 2000 - 11:46:27 PDT