7个版本
0.3.5 | 2024年2月27日 |
---|---|
0.3.4 | 2024年2月16日 |
0.2.4 | 2024年2月16日 |
0.1.2 | 2024年2月13日 |
#85 in 渲染
每月286次下载
31KB
707 行
kopki
Simple graphical engine, based on wgpu and winit.
最小示例
use kopki::{
wgpu, winit, core::context::Context
};
use winit::{
event::{Event, WindowEvent},
event_loop::EventLoop,
window::WindowBuilder
};
use kopki::{
wgpu, winit, Context
};
use winit::{
event::{Event, WindowEvent},
event_loop::EventLoop,
window::WindowBuilder
};
fn main() {
let ctx = Context::blocked_new();
let event_loop = EventLoop::new().unwrap();
let window = WindowBuilder::new()
.build(&event_loop).expect("failed to build");
let mut surface = ctx.create_surface(&window);
_ = event_loop.run(move |event,elwt| {
match event {
Event::AboutToWait => {
window.request_redraw();
}
Event::WindowEvent { event, .. } => {
match event {
WindowEvent::CloseRequested => elwt.exit(),
WindowEvent::RedrawRequested => {
ctx.render(
&surface,&[],&[],
wgpu::Color {
r: 0.0,
g: 0.0,
b: 0.0,
a: 0.0,
}
)
}
WindowEvent::Resized(size) => {
surface.resize(&ctx, size)
}
_ => ()
}
}
_ => ()
}
})
}
更多示例请查看GitHub仓库中的examples文件夹
依赖项
~8–43MB
~731K SLoC