Ejemplo n.º 1
0
// SetStencilTest configures or disables stencil testing. When stencil testing is
// enabled, the geometry of everything that is drawn afterward will be clipped/stencilled
// out based on a comparison between the arguments of this function and the stencil
// value of each pixel that the geometry touches. The stencil values of pixels are
// affected via Stencil/StencilEXT.
func SetStencilTest(compare CompareMode, value int32) {
	if gl_state.writingToStencil {
		return
	}

	states.back().stencilCompare = compare
	states.back().stencilTestValue = value
	if compare == COMPARE_ALWAYS {
		gl.Disable(gl.STENCIL_TEST)
		return
	}

	if gl_state.currentCanvas != nil {
		gl_state.currentCanvas.checkCreateStencil()
	}

	gl.Enable(gl.STENCIL_TEST)
	gl.StencilFunc(gl.Enum(compare), int(value), 0xFF)
	gl.StencilOp(gl.KEEP, gl.KEEP, gl.REPLACE)
}
Ejemplo n.º 2
0
// SetScissor Sets or disables scissor. The scissor limits the drawing area to a
// specified rectangle. This affects all graphics calls, including Clear.  The
// dimensions of the scissor is unaffected by graphical transformations
// (translate, scale, ...). if no arguments are given it will disable the scissor.
// if x, y, w, h are given it will enable the scissor
func SetScissor(args ...int32) {
	if args == nil {
		gl.Disable(gl.SCISSOR_TEST)
		states.back().scissor = false
	} else if len(args) == 4 {
		x, y, width, height := args[0], args[1], args[2], args[3]
		gl.Enable(gl.SCISSOR_TEST)
		if gl_state.currentCanvas != nil {
			gl.Scissor(x, y, width, height)
		} else {
			// With no Canvas active, we need to compensate for glScissor starting
			// from the lower left of the viewport instead of the top left.
			gl.Scissor(x, gl_state.viewport[3]-(y+height), width, height)
		}
		states.back().scissorBox = []int32{x, y, width, height}
		states.back().scissor = true
	} else {
		panic("incorrect number of arguments to setscissor")
	}
}
Ejemplo n.º 3
0
// ClearScissor will disable all set scissors.
func ClearScissor() {
	gl.Disable(gl.SCISSOR_TEST)
	states.back().scissor = false
}