Replies: 1 comment 9 replies
-
I did this in a project on bevy 0.5 and bevy_webgl, not sure if it still works use bevy::prelude::*;
pub struct FullscreenCanvasPlugin;
impl Plugin for FullscreenCanvasPlugin {
fn build(&self, app: &mut App) {
app.add_system(update_window_size.system());
}
}
fn update_window_size(mut windows: ResMut<Windows>) {
//See: https://github.com/rust-windowing/winit/issues/1491
// TODO: use window resize event instead of polling
use approx::relative_eq;
let web_window = web_sys::window().unwrap();
let width = web_window.inner_width().unwrap().as_f64().unwrap() as f32;
let height = web_window.inner_height().unwrap().as_f64().unwrap() as f32;
let window = windows.get_primary_mut().unwrap();
if relative_eq!(width, window.width()) && relative_eq!(height, window.height()) {
return;
}
info!(
"resizing canvas {:?}, old size {:?}",
(width, height),
(window.width(), window.height())
);
window.set_resolution(width, height);
} But there is hopefully a cleaner way to do it. |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Any examples of achieving a fullscreen in WASM?
Beta Was this translation helpful? Give feedback.
All reactions