setScissor method
Enables and defines a scissor rectangle for clipping rendering.
When scissor testing is enabled, rendering is confined to the specified rectangular area of the canvas.
x
: The x-coordinate of the lower-left corner of the scissor box.y
: The y-coordinate of the lower-left corner of the scissor box (origin at top-left of canvas).width
: The width of the scissor box.height
: The height of the scissor box.
Implementation
void setScissor(int x, int y, int width, int height) {
flush();
if (!_renderState.isScissorEnabled) {
gl.enable(GL.SCISSOR_TEST);
_renderState.isScissorEnabled = true;
}
final glY = _canvas.height - (y + height);
gl.scissor(x, glY, width, height);
_renderState.scissor.set(x, glY, width, height);
}