Crate magma_winit

Crate magma_winit 

Source
Expand description

This crate integrates winit into the Magma API in order to manage application windows.

§Example

fn main() -> Result<(), Box<dyn Error>> {
    let mut app = App::new();
    app.add_module(WinitModule);
    // Add the system to close created windows.
    // Windows should not be closed in a startup system, bc it might cause the app to hang.
    app.add_systems::<Update>(&[(close_windows, "close_windows", &[])]).unwrap();
    // create a window
    // The winit module will create a single window on startup. That means there will now be two.
    app.world.create_entity((Window::new().with_title("test"),))?;
    app.run();
    Ok(())
}

// system for closing the opened windows
fn close_windows(world: &World) {
    // close windows
    world
        .query::<(Window,)>()
        .unwrap()
        .iter()
        .for_each(|window| window.delete());
}

Modules§

windows

Structs§

WinitModule
The WinitModule adds winit as a backend for magma_windowing. It also automatically creates one window on application start.
WrappedApp