wasm-bindgen
wasm-bindgen copied to clipboard
Handing 'opaque' framebuffers in WebXR
So the WebXR spec has these 'opaque' framebuffers that you're meant to bind in WebGL:
https://developer.mozilla.org/en-US/docs/Web/API/XRWebGLLayer/framebuffer
It turns out that what 'opaque' means in this context is that the .framebuffer property will just straight-up report itself as null, yet is still bindable with gl.bindFramebuffer. This means that the XrWebGlLayer.framebuffer getter is always going to be None.
We need to come up with a work-around for this.
I've been using the changes in https://github.com/rustwasm/wasm-bindgen/pull/2863 for a while now and changing it from -> Option<WebGlFramebuffer> to -> WebGlFramebuffer has worked fine. We need a good way to override the generated function signature though.
This is still a problem, but can easily be worked around with:
let base_layer: web_sys::XrWebGlLayer = ...;
let framebuffer: web_sys::WebGlFramebuffer = js_sys::Reflect::get(&base_layer, &"framebuffer".into()).unwrap().into();