update method

void update()

Update the underlying WebGL texture with the source of this RenderTexture.

The source of the RenderTexture is an ImageElement, CanvasElement or VideoElement. If changes are made to the source you have to call the update method to apply those changes to the WebGL texture.

The progress in a VideoElement will automatically updated the RenderTexture and you don't need to call the update method.


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


  final scissors = _renderingContext!.isEnabled(gl.WebGL.SCISSOR_TEST);
  if (scissors) _renderingContext!.disable(gl.WebGL.SCISSOR_TEST);

  const target = gl.WebGL.TEXTURE_2D;

  if (_textureSourceWorkaround) {
    _canvas!.context2D.drawImage(source!, 0, 0);
        .texImage2D(target, 0, pixelFormat, pixelFormat, pixelType, _canvas);
  } else {
        .texImage2D(target, 0, pixelFormat, pixelFormat, pixelType, _source);

  if (scissors) _renderingContext!.enable(gl.WebGL.SCISSOR_TEST);