#游戏引擎 #Windows #应用程序 #magma3-d #API #magma-api #负责人

magma_winit

是 Magma-API 的一部分,它是 Magma3D 游戏引擎的 API。该模块负责处理窗口。

6 个版本

0.1.0-alpha.52023年12月18日
0.1.0-alpha.42023年12月16日

#2171 in 游戏开发


2 crates 中使用

MIT 许可证

12KB
186

magma_winit

该软件包负责初始化和处理 Magma3D 应用程序的窗口。


lib.rs:

该软件包将 winit 集成到 Magma3D 引擎中。以下是一个基本用法示例

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);
}
}
}

依赖关系

~3–20MB
~252K SLoC