Robbo
05-28-2002, 01:08 AM
The fragment below shows how I've setup my stencil test. What I'm trying to do is draw a load of polygons with holes in (using alpha test) and then to draw a further bunch of polygons which may or may not show through the holes. I have had problems with z buffer accurracy when two polygons are really close to each other. Polygon offset hasn't worked too well because I'm dealing with cylinders (see www.thermoteknix.com (http://www.thermoteknix.com) for a screenshot!). Thanks for any advice.
glEnable ( GL_STENCIL_TEST );
glStencilFunc ( GL_ALWAYS, 1, 1 );
glStencilOp ( GL_KEEP, GL_ZERO,GL_REPLACE );
DrawPolygonsWithHolesIn ();
glStencilFunc ( GL_EQUAL, 1, 0 );
glStencilMask ( GL_FALSE );
DrawPolygonsUnderneath ();
glDisable ( GL_STENCIL_TEST );
glEnable ( GL_STENCIL_TEST );
glStencilFunc ( GL_ALWAYS, 1, 1 );
glStencilOp ( GL_KEEP, GL_ZERO,GL_REPLACE );
DrawPolygonsWithHolesIn ();
glStencilFunc ( GL_EQUAL, 1, 0 );
glStencilMask ( GL_FALSE );
DrawPolygonsUnderneath ();
glDisable ( GL_STENCIL_TEST );