• Template buffering and Mask
// Close all channels for color buffering
gl.colorMask(false.false.false.false);
// Draw a mask to update the template buffer data
gl.stencilFunc(gl.EQUAL, 1.0xFF); gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR); gl.drawElements(...) ; gl.stencilFunc(gl.EQUAL,1.0xFF);
// Turn on all channels for color buffering
gl.colorMask(true.true.true.true);
// Draw an image, subject to template bufferinggl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); gl.drawElements(...) ;Copy the code