This is an egui integration for winit and vulkano.
You'll need a Vulkano target image as an input to which the UI will be painted. The aim of this is to allow a simple enough API to separate UI nicely out of your renderer and make it easy to build your immediate mode UI with Egui.
Arc<Queue>
and Vulkano's winit surface Arc<Surface<Window>>
rust
// Has its own renderpass. Modify GuiConfig to determine image clear behavior etc.
let mut gui = Gui::new(&event_loop, renderer.surface(), renderer.queue(), renderer.swapchain_format(), GuiConfig::default());
// Or with subpass. This means that you must create the renderpass yourself. Egui subpass will then draw on your
// image.
let mut gui = Gui::new_with_subpass(&event_loop, renderer.surface(), renderer.queue(), renderer.swapchain_format(), subpass, GuiConfig::default());
gui
integration with WindowEvent
rust
gui.update(&event);
Event::RedrawRequested
before you render
```rust
gui.immediate_ui(|gui| {
let ctx = gui.context();
// Fill egui UI layout here
});// Or
gui.begin_frame(); // fill egui layout...
// And when you render with gui.draw_on_image(..)
, this will finish the egui frame
5. Render gui via your renderer on any image or most likely on your swapchain images:
rust
// Acquire swapchain future
let beforefuture = renderer.acquire().unwrap();
// Render gui by passing the acquire future (or any) and render target image (swapchain image view)
let afterfuture = gui.drawonimage(beforefuture, renderer.swapchainimageview());
// Present swapchain
renderer.present(afterfuture, true);
// ----------------------------------
// Or if you created the integration with subpass
let cb = gui.drawonsubpassimage(framebufferdimensions);
drawpass.execute(cb);
``
Note that Egui prefers UNORM render targets. Using an output format with sRGB requires
GuiConfig::allowsrgbrendertarget` to be set, to acknowledge that using sRGB will cause minor discoloration of UI elements due to blending in linear color space and not sRGB as Egui expects.
See the examples directory for better usage guidance.
Remember, on Linux, you need to install following to run Egui
bash
sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
sh
./run_all_examples.sh
This integration would not have been possible without the examples from vulkano-examples or eguiwinitashvkmem.