Crates.io | egui-winit-ash-integration |
lib.rs | egui-winit-ash-integration |
version | 0.6.0 |
source | src |
created_at | 2021-09-09 15:51:50.045014 |
updated_at | 2023-12-14 13:28:34.173006 |
description | This is the egui integration crate for winit and ash. |
homepage | https://docs.rs/egui-winit-ash-integration |
repository | https://github.com/MatchaChoco010/egui-winit-ash-integration |
max_upload_size | |
id | 448928 |
size | 160,961 |
This is the egui integration crate for egui-winit and ash. The default GPU allocator is gpu_allocator, but you can also implement AllocatorTrait.
This crate does not support multi-viewports for multi-window since version 0.24 of egui.
egui-ash is an alternative crate, which supports multi-viewports, so please take a look at this one.
cargo run --example example
cargo run --example user_texture
fn main() -> Result<()> {
let event_loop = EventLoop::new();
// (1) Call Integration::<Arc<Mutex<Allocator>>>::new() in App::new().
let mut app = App::new(&event_loop)?;
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Poll;
match event {
Event::WindowEvent { event, window_id: _ } => {
// (2) Call integration.handle_event(&event).
let _response = app.egui_integration.handle_event(&event);
match event {
WindowEvent::Resized(_) => {
app.recreate_swapchain().unwrap();
}
WindowEvent::ScaleFactorChanged { .. } => {
// (3) Call integration.recreate_swapchain(...) in app.recreate_swapchain().
app.recreate_swapchain().unwrap();
}
WindowEvent::CloseRequested => {
*control_flow = ControlFlow::Exit;
}
_ => (),
}
},
Event::MainEventsCleared => app.window.request_redraw(),
Event::RedrawRequested(_window_id) => {
// (4) Call integration.begin_frame(), integration.end_frame(&mut window),
// integration.context().tessellate(shapes), integration.paint(...)
// in app.draw().
app.draw().unwrap();
},
_ => (),
}
})
}
// (5) Call integration.destroy() when drop app.
Full example is in examples directory
gpu-allocator-feature
- Enables the gpu-allocator crate.
The other features directly control the underlying egui_winit features
MIT OR Apache-2.0