Crate magma_winit
source ·Expand description
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);
}
}
}
Re-exports
pub use winit;
Modules
- The
Windows
resource
Structs
- Adding the
WinitModule
to anApp
adds functionality for creating and managing windows. It also automatically adds one window on application start.