texImage2DfromImage method

Future<void> texImage2DfromImage(
  1. int target,
  2. Image image, {
  3. int level = 0,
  4. int internalformat = WebGL.RGBA,
  5. int format = WebGL.RGBA,
  6. int type = WebGL.UNSIGNED_BYTE,
})

Implementation

Future<void> texImage2DfromImage(
  int target,
  Image image, {
  int level = 0,
  int internalformat = WebGL.RGBA,
  int format = WebGL.RGBA,
  int type = WebGL.UNSIGNED_BYTE,
}) async {
  final completer = Completer<void>();
  final bytes = (await image.toByteData())!;
  final hblob = html.Blob([bytes]);
  final imageDom = html.ImageElement();
  imageDom.crossOrigin = "";
  imageDom.src = html.Url.createObjectUrl(hblob);

  imageDom.onLoad.listen((e) {
    completer.complete();
    texImage2D_NOSIZE(target, level, internalformat, format, type, imageDom);
  });

  return completer.future;
}