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 (is_overlay = false means that the renderpass will clear the image, true means
// that the caller is responsible for clearing the image
let mut gui = Gui::new(renderer.surface(), renderer.queue(), false);
// Or with subpass
let mut gui = Gui::new_with_subpass(renderer.surface(), renderer.queue(), subpass);
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
renderer.render(&mut gui); //... and inside render function:
// Draw, where
// future = acquired future from previousframeend.join(swapchainacquirefuture) and
// imageviewtodrawon = the final image onto which you wish to render UI, usually e.g.
// self.finalimages[imagenum].clone() = one of your swap chain images.
let afterfuture = gui.drawonimage(future, imageviewtodraw_on);
// Or if you created the integration with subpass
let cb = gui.drawonsubpassimage(framebufferdimensions);
draw_pass.execute(cb);
``
6. Finish your render by waiting on the future
gui.drawreturns. See
finish` function in example renderers.
Or in the case of subpass, execute your commands.
See the examples directory for a more wholesome example which uses Vulkano developers' frame system to organize rendering.
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
cargo run --example wholesome
cargo run --example minimal
cargo run --example subpass
This integration would not have been possible without the examples from vulkano-examples or eguiwinitashvkmem.