Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upFeature: webgl/stdweb backend #1900
Comments
This comment has been minimized.
This comment has been minimized.
chpio
commented
Jul 2, 2018
•
|
is there a easy way to compile spirv_cross to wasm/include it in the build? also it would be really nice to run spriv_cross as a build step instead of including it into the build as a dependency. |
This comment has been minimized.
This comment has been minimized.
|
I made some progress on this: I managed to create true C-like bindings to webgl by borrowing The net result is that I can call the normal OpenGL API on the |
This comment has been minimized.
This comment has been minimized.
|
@Diggsey u r da the best, man! Please keep up cracking this nut, we are excited to see this coming :) |
This comment has been minimized.
This comment has been minimized.
Boscop
commented
Aug 11, 2018
|
I'm also very interested in this, what's the current status of this? :) |
This comment has been minimized.
This comment has been minimized.
|
@Diggsey is there a branch somewhere that contains your progress on this? |
This comment has been minimized.
This comment has been minimized.
cretz
commented
Sep 26, 2018
|
As an alternative to stdweb, consider the recently announced web-sys crate, e.g. canvas.get_context("webgl").unwrap().dyn_into::<web_sys::WebGlRenderingContext>() |
This comment has been minimized.
This comment has been minimized.
aep
commented
Oct 13, 2018
|
whats missing here, anything we can help with? |
This comment has been minimized.
This comment has been minimized.
luckielordie
commented
Oct 19, 2018
|
Is anyone working on this? |
This comment has been minimized.
This comment has been minimized.
|
Looks like we are back to square one here, with @Diggsey disappearing. At least we can consider |
This comment has been minimized.
This comment has been minimized.
Vurich
commented
Oct 26, 2018
|
I'm working on a Processing-like framework in Rust and this would be amazing to allow me to have an online sketchpad similar to a combination of https://valentin.dasdeck.com/processing/ and the Rust playground. |
This comment has been minimized.
This comment has been minimized.
luckielordie
commented
Nov 22, 2018
|
I'm planning on giving this a go with web-sys. Obviously it's a matter of time for me. Any help people could give me understanding the HAL Interface would be a major help. |
This comment has been minimized.
This comment has been minimized.
|
@luckielordie HAL interface is basically Vulkan, plus a bit of type sugar in a few places. |
This comment has been minimized.
This comment has been minimized.
luckielordie
commented
Nov 23, 2018
I'm going to need to brush up on my Vulkan then! |
This comment has been minimized.
This comment has been minimized.
luckielordie
commented
Nov 23, 2018
•
|
A quick update, I've forked and created a branch here. If you want to contribute you're more than welcome to request access and I'll open it up. I'm fairly new to Rust so I'll always appreciate a more experienced eye. |
This comment has been minimized.
This comment has been minimized.
|
@luckielordie Might be preferable for maintainability reasons if you directly integrate webgl support into the gl backend, instead of having to separate backends. |
This comment has been minimized.
This comment has been minimized.
mmacedoeu
commented
Nov 26, 2018
|
I have also started some proof of concept using stdweb. I choose stdweb for two reasons: it has a broader scope with more stuff included and it plans to migrate to web-sys on the future. So far I come to this challenging problems: spirv-cross should move to build.rs stage, glutin should be replaced with winit or plain stdweb, threads and structure like Starc should be rethought to web-friendly maybe just like crate yew use webworkers for concurrency. I also a brand new backend instead of using gl, it may be possible to merge both in the end and use a lot of conditional compile flags but so far I am trying to just make things work and optimize latter on. |
This comment has been minimized.
This comment has been minimized.
wow, that sounds like a world of pain, tbh Btw, what do you mean by "spirv-cross should move to build.rs stage"? |
This comment has been minimized.
This comment has been minimized.
mmacedoeu
commented
Nov 26, 2018
•
|
spirv-cross is a binding to native c/cpp lib so I think rustc will not be able to compite it to WASM, so you need to try to compile it (cross) using emsdk or just make all spirv to glsl transpile be done in build.rs pre-compilation stage so there is NO runtime translation done. Still I have not look into possible implications for this. It really is a pain cave, any insights? |
This comment has been minimized.
This comment has been minimized.
I don't think we should need a lot of conditional compile flags for the gl backend, could we just use feature flags (optionally with a macro)? The function signatures should almost be the exact same between OpenGL ES (which we need to support anyway) and WebGL.
We need to allow runtime translation of SPIR-V to GLSL with spirv_cross, so it's not possible to do it all in build.rs. I think compiling the wrapper in spirv_cross to wasm is fine to start with. I can help with this - the wrapper exists in spirv_cross. |
This comment has been minimized.
This comment has been minimized.
|
I have an experimental branch rendering the quad example using WebGL2 and web-sys (through the I'll put the branch somewhere soon if anyone's interested, but there a few other issues we need to work through:
We can probably start to split these into issues and address them individually. Edit: I posted the branch here for reference master...grovesNL:webgl-hacking It's prototype quality at the moment (breaks the regular gl backends because of the temporary logging code, only supports quad, unformatted, etc.) but should give us some ideas about how to properly support it through the points mentioned above. |
This comment has been minimized.
This comment has been minimized.
|
Awesome. I really don't have the time or energy to majorly contribute to this, but if it becomes a bit more mature I'll probably be trying to use it in ggez, which will probably result in lots of issues and hopefully attached fixes. :D The event loop stuff is interesting, what do you need that winit doesn't provide? I was under the impression there was some pretty srs work in progress to make it possible to work more nicely on web already. |
This comment has been minimized.
This comment has been minimized.
|
Yeah I plan to keep working through these issues for a while. I’m currently looking into the feasibility of a thin abstraction to combine WebGL and OpenGL types/signatures with some helpers we’ll need. I’m not sure of the situation with winit/wasm support but that would be the ideal solution when it’s ready. I scanned the issue tracker a few days ago and it seemed like it was still planned or early WIP so didn’t try it out. If it’s already supported then that would be great. If it’s not supported yet, we could just have a simple wrapper to simplify the boilerplate for now. |
This comment has been minimized.
This comment has been minimized.
|
A small update: I started investigating the first two points by creating abstractions over WebGL + OpenGL types/function signatures with primitive key types (which are There's an example in that repository that shows how the abstraction works at the moment. Also until we have something like winit on wasm to help with the event loop, events like key presses, resizing, etc. are still target-specific. Any feedback about this abstraction would be really helpful! If this experiment turns out to be useful then I should be able to quickly recreate my branch on top of it. |
This comment has been minimized.
This comment has been minimized.
|
Looks pretty reasonable to me, from what little I know of such things. My only question would be, can you use a trait object rather than an enum for dispatching on Making |
This comment has been minimized.
This comment has been minimized.
|
Yeah definitely. I’m hoping this enum will mostly disappear if we could get wasm bindgen to automatically create a base trait for any common signatures. Maybe I could use a simple macro to avoid some of the repetition for now. |
This comment has been minimized.
This comment has been minimized.
|
I've made some more progress in #2554 if anyone wants to take a look. |
bors bot
added a commit
that referenced
this issue
Jun 8, 2019
This comment has been minimized.
This comment has been minimized.
erlend-sh
commented
Jun 9, 2019
|
Resolved by #2554? |

Diggsey commentedApr 1, 2018
Using https://docs.rs/webgl_stdweb/0.1.0/webgl_stdweb/struct.GLContext.html
I've tried a couple of times to integrate this, but it's very non-trivial: obviously I'd like to reuse as much as possible from the GL backend, but it was never designed to have a separation between the code which translates GFX concepts into GL concepts, and the code which actually interacts with the OpenGL API.