setViewport method

void setViewport(
  1. int x,
  2. int y,
  3. int width,
  4. int height,
)

Sets the viewport.

The viewport defines the area of the canvas where rendering will occur.

  • x: The x-coordinate of the top-left corner of the viewport.
  • y: The y-coordinate of the top-left corner of the viewport.
  • width: The width of the viewport.
  • height: The height of the viewport.

Implementation

void setViewport(int x, int y, int width, int height) {
  if (_renderState.viewport.x != x ||
      _renderState.viewport.y != y ||
      _renderState.viewport.width != width ||
      _renderState.viewport.height != height) {
    _renderState.viewport.set(x, y, width, height);
    _renderer.setViewport(x, y, width, height);
  }
}