pex-context icon indicating copy to clipboard operation
pex-context copied to clipboard

ImageBitmap is only supported in WebGL2

Open vorg opened this issue 3 years ago • 7 comments

As per https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D

Should we warn in pex-context or rely on browser to fail? Is creates issue here https://github.com/pex-gl/pex-renderer/blob/v4/loaders/glTF.js#L1234

vorg avatar Jun 08 '22 10:06 vorg

I'd say yes, warning in pex-context but also overwrite supportImageBitmap by checking isWebGL2 in pex-renderer.

dmnsgn avatar Jun 08 '22 10:06 dmnsgn

Why do we not support in in gltf in Safari?

From https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap Screenshot 2022-06-08 at 12 04 38

vorg avatar Jun 08 '22 11:06 vorg

Btw FF gives better error in WebGL1 WebGLRenderingContext.texImage2D: Argument 9 does not implement interface ArrayBufferViewOrNull.

vorg avatar Jun 08 '22 11:06 vorg

Possible fix here https://stackoverflow.com/questions/42073596/webglrenderingcontext-teximage2d-does-not-implement-interface-arraybuffervieworn

Hmm if i do this in WebGL1 then it works.. does it mean ImageBitmap is considered HTMLElement in WebGL1 and ArrayBuffer view compatible in WebGL2 only?

Screenshot 2022-06-08 at 12 15 40

vorg avatar Jun 08 '22 11:06 vorg

Why do we not support in in gltf in Safari?

Because it doesn't support options.colorSpaceConversion which is GLTF spec: https://developer.mozilla.org/en-US/docs/Web/API/createImageBitmap#browser_compatibility FF >= 98 supports it so I didn't added a check for it.

dmnsgn avatar Jun 08 '22 12:06 dmnsgn

Proposed change: check if ImageBitmap in webgl.

   }
 
   const img = opts.data ? opts.data : opts;
-  if (img && img.nodeName) {
+  if (
+    (img && img.nodeName) ||
+    (!ctx.capabilities.isWebGL2 && img instanceof ImageBitmap)
+  ) {
   

dmnsgn avatar Jun 08 '22 14:06 dmnsgn

Looks good to me

vorg avatar Jun 09 '22 08:06 vorg