Re: using stencil buffer to mask areas

New Message Reply Date view Thread view Subject view Author view

From: Angus Dorbie (dorbie++at++sgi.com)
Date: 06/20/2000 13:36:37


It's not clear where you require of your stencil mask.

Is it screen space (2D in the window)

Is it Object Space (local to the object and transforming with it)

Is it Object Space positioned and screen space oriented (a 2D rectangle
transforming with the object)

Or is it something else entirely?

It looks like you are only drawing a single quad and this quad will be
transformed through the orientation of the model which I don't think is
what you need given the constant z value (which in performer should
probably be constant y if you were in the right transform space anyway).
Would glScissor be a better option for you?

Cheers,Angus.

Aron Bartle wrote:
>
> 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
>
>

-- 
For Performer+OpenGL tutorials http://www.dorbie.com/

"In the middle of difficulty lies opportunity." --Albert Einstein


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Tue Jun 20 2000 - 13:36:46 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.