#gui #winit #ash #vulkan #gpu-allocator

egui-winit-ash-integration

This is the egui integration crate for winit and ash

5 unstable releases

0.3.0 Jan 7, 2023
0.2.0 Oct 24, 2021
0.1.2 Sep 9, 2021
0.1.1 Sep 9, 2021
0.1.0 Sep 9, 2021

#11 in #winit

Download history 26/week @ 2023-02-14 9/week @ 2023-02-21 7/week @ 2023-02-28 9/week @ 2023-03-07 8/week @ 2023-03-14 6/week @ 2023-03-21 19/week @ 2023-03-28 8/week @ 2023-04-04 20/week @ 2023-04-11 1/week @ 2023-04-18 10/week @ 2023-04-25 14/week @ 2023-05-02 15/week @ 2023-05-09 5/week @ 2023-05-16 19/week @ 2023-05-23 27/week @ 2023-05-30

71 downloads per month
Used in despero

MIT/Apache

77KB
1.5K SLoC

egui-winit-ash-integration

Latest version Documentation MIT Apache egui version: 0.20.1

This is the egui integration crate for egui-winit and ash. The default GPU allocator is gpu_allocator, but you can also implement AllocatorTrait.

Example

cargo run --example example
cargo run --example user_texture

Usage

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

License

MIT OR Apache-2.0

Dependencies

~12–21MB
~438K SLoC