6 releases
0.1.0-alpha.5 | Dec 18, 2023 |
---|---|
0.1.0-alpha.4 | Dec 16, 2023 |
#528 in #windows
Used in 2 crates
12KB
186 lines
magma_winit
This crate is responsable for initializing and handling windows of a Magma3D application.
lib.rs
:
This crates integrates winit
into the Magma3D engine.
Here is a basic usage example:
use magma_app::{App, SystemType, World};
use magma_winit::{windows::Windows, WinitModule};
let mut app = App::new();
app.add_module(WinitModule);
// spawn a window before running the app
app.world.get_resource_mut::<Windows>().unwrap().spawn();
app.add_systems(
SystemType::Update,
(vec![], vec![&open_windows, &close_windows]),
);
app.run();
// open a new window every update
fn open_windows(world: &mut World) {
world.get_resource_mut::<Windows>().unwrap().spawn();
}
// close all the windows when 4 have been spawned
fn close_windows(world: &mut World) {
let window_resource = world.get_resource_mut::<Windows>().unwrap();
if window_resource.windows.len() == 4 {
for i in 0..4 {
window_resource.despawn(i);
}
}
}
Dependencies
~3–20MB
~251K SLoC