#game-engine #windows #applications #magma3-d #api #magma-api #responsable

magma_winit

Part of the Magma-API, which is the API of the Magma3D game engine. This is responsable for handling windows.

6 releases

0.1.0-alpha.5 Dec 18, 2023
0.1.0-alpha.4 Dec 16, 2023

#1810 in Game dev

37 downloads per month
Used in 2 crates

MIT license

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

~2–17MB
~218K SLoC