#egui-integration #ash #winit #vulkan #gpu-allocator

egui-winit-ash-integration

This is the egui integration crate for winit and ash

9 releases (5 breaking)

0.6.0 Dec 14, 2023
0.5.0 Oct 12, 2023
0.4.1 Oct 11, 2023
0.3.0 Jan 7, 2023
0.1.2 Sep 9, 2021

#514 in GUI

Download history 58/week @ 2024-07-26 6/week @ 2024-08-02 10/week @ 2024-09-20 3/week @ 2024-09-27

136 downloads per month
Used in despero

MIT/Apache

82KB
1.5K SLoC

egui-winit-ash-integration

Latest version Documentation MIT Apache egui version: 0.23.0

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.

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

Feature flags

gpu-allocator-feature - Enables the gpu-allocator crate.

The other features directly control the underlying egui_winit features

License

MIT OR Apache-2.0

Dependencies

~12–44MB
~749K SLoC