Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wasm #992

Merged
merged 3 commits into from
Feb 11, 2025
Merged

Fix wasm #992

merged 3 commits into from
Feb 11, 2025

Conversation

tychedelia
Copy link
Collaborator

@tychedelia tychedelia commented Feb 11, 2025

Because we weren't creating a default window in WindowPlugin, the renderer wasn't able to initialize with the correct surface to attach to the canvas. This PR fixes this by doing some hacks when compiling under wasm32 to create the default window and then update it to whatever the user provides in their WindowBuilder. This only supports a single primary window on web.

Ideally, long term, we'd figure out a better pattern for spawning a new canvas element when the window is created dynamically, rather than relying on Bevy's window initialization logic in the renderer. I'm sure this is possible, just need some more consultation with some other Bevy folks to figure out how to do it.

Test with:

cargo build --release --example draw --target wasm32-unknown-unknown
wasm-bindgen --out-name draw \ 
    --out-dir examples/wasm/target \
    --target web target/wasm32-unknown-unknown/release/examples/draw.wasm
basic-http-server examples/wasm

image

@tychedelia tychedelia merged commit 387ec36 into nannou-org:bevy-refactor Feb 11, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant