beginRenderMask method
Implementation
@override
void beginRenderMask(RenderState renderState, RenderMask mask) {
_activeRenderProgram.flush();
// try to use the scissor rectangle for this mask
if (mask is ScissorRenderMask) {
final scissor = mask.getScissorRectangle(renderState);
if (scissor != null) {
final last = _getLastScissorValue();
final next = last == null ? scissor : scissor.intersection(last);
_getMaskStates().add(_ScissorMaskState(mask, next));
_updateScissorTest(next);
return;
}
}
// update the stencil buffer for this mask
final stencil = _getLastStencilValue() + 1;
_renderingContext.enable(gl.WebGL.STENCIL_TEST);
_renderingContext.stencilOp(gl.WebGL.KEEP, gl.WebGL.KEEP, gl.WebGL.INCR);
_renderingContext.stencilFunc(gl.WebGL.EQUAL, stencil - 1, 0xFF);
_renderingContext.colorMask(false, false, false, false);
mask.renderMask(renderState);
_activeRenderProgram.flush();
_renderingContext.stencilOp(gl.WebGL.KEEP, gl.WebGL.KEEP, gl.WebGL.KEEP);
_renderingContext.colorMask(true, true, true, true);
_getMaskStates().add(_StencilMaskState(mask, stencil));
_updateStencilTest(stencil);
}