10 releases
Uses new Rust 2024
| 0.1.0-alpha.9 | Aug 21, 2025 |
|---|---|
| 0.1.0-alpha.8 | Jul 22, 2025 |
| 0.1.0-alpha.6 | Jun 4, 2025 |
| 0.1.0-alpha.5 | Dec 18, 2023 |
#992 in Game dev
23 downloads per month
Used in 2 crates
135KB
2.5K
SLoC
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());
}
magma_winit
This crate provides backends for magma_windowing as well as magma_input.
Features
- windowing backend
- input backend
Usage
This crate should be used together with the rest of the magma_api.
Add this to your Cargo.toml:
[dependencies]
magma_winit = "0.1.0-alpha.9"
Example (with magma_api)
use magma_api::App;
use magma_api::magma_winit::WinitModule;
fn main() {
let mut app = App::new();
// Add the module (also adds InputModule and WindowingModule automatically)
app.add_module(WinitModule);
// run the app
app.run();
}
Cargo Features
currently no features
Disclaimer
This crate is not production ready.
Dependencies
~9–26MB
~463K SLoC