updateTexture method

Future<void> updateTexture(
  1. FlutterAngleTexture texture, [
  2. WebGLTexture? sourceTexture
])

Implementation

Future<void> updateTexture(FlutterAngleTexture texture, [WebGLTexture? sourceTexture]) async {
  if (sourceTexture != null) {
    _rawOpenGl.glClearColor(0.0, 0.0, 0.0, 0.0);
    _rawOpenGl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
    _rawOpenGl.glViewport(0, 0, (texture.options.width*texture.options.dpr).toInt(),( texture.options.height*texture.options.dpr).toInt());
    _worker.renderTexture(sourceTexture, isFBO: Platform.isAndroid);
    _rawOpenGl.glFinish();
  }

  // If we have an iOS EGL surface created from IOSurface, use it
  if ((_isApple || Platform.isAndroid) && texture.surfaceId != nullptr) {
    eglSwapBuffers(_display, texture.surfaceId!);
    if (_isApple) {
      await _channel.invokeMethod('textureFrameAvailable', texture.textureId);
    }
    return;
  }

  _rawOpenGl.glFlush();
  assert(_activeFramebuffer != null, 'There is no active FlutterGL Texture to update');
  await _channel.invokeMethod('updateTexture', {"textureId": texture.textureId, "location": texture.loc});
}