void GL::EnableStencilTest(UnaryStencilTest aTest, GLuint aTestMask, StencilOperation aOp, GLuint aWriteMask) { switch (aTest) { case PASS_IF_NOT_ZERO: EnableStencilTest(PASS_IF_NOT_EQUAL, 0, aTestMask, aOp, aWriteMask); return; case PASS_IF_ALL_SET: EnableStencilTest(PASS_IF_EQUAL, aTestMask, aTestMask, aOp, aWriteMask); return; } }
bool nuiGLDrawContext::ResetClipShape(bool Invert) { EnableStencilTest(true); //glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glStencilMask(~0); mClipShapeValue = 1; glClearStencil(Invert?mClipShapeValue:0); glClear(GL_STENCIL_BUFFER_BIT); EnableStencilTest(false); //glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glStencilMask(0); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_EQUAL, mClipShapeValue, 255); return true; }
bool nuiGLDrawContext::AddClipShape(nuiShape& rShape, bool Invert) { EnableStencilTest(true); glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE); glStencilMask(~0); // Now draw the shape in the stencil buffer: GLenum value = Invert? 0: mClipShapeValue; glStencilFunc(GL_ALWAYS, value, 255); glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE); DrawShape(&rShape, eFillShape); // Now lets get back to the mode we were in before the stencill fun: glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); glStencilMask(0); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilFunc(GL_EQUAL, mClipShapeValue, 255); return true; }