resize method

void resize(
  1. int width,
  2. int height
)

Implementation

void resize(int width, int height) {
  if (_source is VideoElement) {
    throw StateError('RenderTexture is not resizeable.');
  } else if (_width == width && _height == height) {
    // there is no need to resize the texture
  } else if (_source == null) {
    _width = width;
    _height = height;

    if (_renderContext == null || _texture == null) return;
    if (_renderContext!.contextIdentifier != contextIdentifier) return;

    const target = gl.WebGL.TEXTURE_2D;

    _renderContext!.activateRenderTexture(this);
    _renderingContext!.texImage2D(
        target, 0, pixelFormat, _width, _height, 0, pixelFormat, pixelType);
  } else {
    _width = width;
    _height = height;
    _canvas = _source = CanvasElement(width: _width, height: _height);
  }
}