emoon / rust_minifb

Cross platfrom window and framebuffer crate for Rust
MIT License
1.04k stars 99 forks source link

[wasm] Fix raw handles, delay `getContext` call to be WebGPU compatible #368

Closed Wumpf closed 1 month ago

Wumpf commented 1 month ago

Also, fixed various warnings & added a CI step to check the wasm target.

The reason getContext have to be delayed here is that this stateful: Once getContext is called with one type of context (2d, webgl or webgpu), any future call with a different type will fail. -> Previously, it was not possible to use the canvas with a WebGL/WebGPU context since minifb would call .get_context("2d") during initialization.

Tested this on https://github.com/Wumpf/minifb_wgpu_web_and_desktop (at https://github.com/Wumpf/minifb_wgpu_web_and_desktop/commit/e39be06686b9b8662d27fd4cb0a3787dfaee172d)

Wumpf commented 1 month ago

ah the ci config didn't age well, have to fix this up

Wumpf commented 1 month ago

done! Couldn't have asked for a better example why the ci check is needed than the unwrap_or(return false) that slipped onto master meanwhile ;-)

emoon commented 1 month ago

Awesome! Thanks for the fixes :)