egui integration for ash (Vulkan).

Related tags

GUI egui-ash
Overview

egui-ash

Latest version Documentation MIT Apache2.0 egui: 0.24.1 ash: 0.37.3

egui integration for ash (Vulkan).

This crate natively supports the multi-viewports feature added since version 0.24 of egui.

You can use gpu_allocator as the default allocator by the gpu-allocator feature. You can also use your own allocator by implementing the Allocator trait.

Example

simple

simple

cargo run --release --example egui_ash_simple

vulkan

vulkan

cargo run --release --example egui_ash_vulkan

images

images

cargo run --release --example images

multi viewports

multi viewports

cargo run --release --example multi_viewports

native images

native image

cargo run --release --example native_image

scene view

scene view

cargo run --release --example scene_view

tiles

tiles

cargo run --release --example tiles

Usage

// (1) Create a App struct that implements the `egui_ash::App` trait.
struct MyApp;
impl egui_ash::App for MyApp {
    fn ui(
        &mut self,
        ctx: &egui::CtxRef,
        integration_context: &mut egui_ash::IntegrationContext,
    ) {
        // (2) draw ui here
        egui::Window::new("Hello world").show(ctx, |ui| {
            ui.label("Hello world!");
        });
    }

    fn request_redraw(&mut self, _viewport_id: egui::ViewportId) -> HandleRedraw {
      // (3) return `HandleRedraw::Auto` if you want to draw only egui.
      HandleRedraw::Auto
      // (4) ...or return `HandleRedraw::Handle` if you want to draw with ash.
      // NOTE: You must call `egui_cmd.update_swapchain` inside render function
      // when you first render and when you recreate the swapchain.
      HandleRedraw::Handle(Box::new(|size, egui_cmd| render(size, egui_cmd)))
    }
}

// (5) Create a AppCreator struct that implements the `egui_ash::AppCreator` trait.
struct MyAppCreator;
impl egui_ash::AppCreator for MyAppCreator {
    type App = MyApp;

    // (6) new method receives `egui_ash::CreationContext` and
    // returns `Self::App` and `egui_ash::AshRenderState`.
    fn new(&self, cc: CreationContext) -> (Self::App, AshRenderState<Arc<Mutex<Allocator>>>) {
        // create vk objects
        let entry = create_entry();
        let (instance, debug_utils_loader, debug_messenger) =
            create_instance(&cc.required_instance_extensions, &entry);
        let surface_loader = create_surface_loader(&entry, &instance);
        let surface = create_surface(&entry, &instance, cc.main_window);
        let (physical_device, _physical_device_memory_properties, queue_family_index) =
            create_physical_device(
                &instance,
                &surface_loader,
                surface,
                &cc.required_device_extensions,
            );
        let (device, queue) = create_device(
            &instance,
            physical_device,
            queue_family_index,
            &cc.required_device_extensions,
        );
        let swapchain_loader = create_swapchain_loader(&instance, &device);
        let command_pool = create_command_pool(&device, queue_family_index);

        // create allocator
        let allocator = {
            Allocator::new(&AllocatorCreateDesc {
                instance: instance.clone(),
                device: device.clone(),
                physical_device,
                debug_settings: Default::default(),
                buffer_device_address: false,
                allocation_sizes: Default::default(),
            })
            .expect("Failed to create allocator")
        };
        let allocator = Arc::new(Mutex::new(allocator));

        let ash_render_state = AshRenderState {
            entry,
            instance,
            physical_device,
            device,
            surface_loader,
            swapchain_loader,
            queue,
            queue_family_index,
            command_pool,
            allocator,
        };

        (Self, ash_render_state)
    }
}

// (7) Call `egui_ash::run` with `AppCreator` struct.
fn main() {
    egui_ash::run(
        MyAppCreator,
        RunOption {
            viewport_builder: Some(egui::ViewportBuilder::default().with_title("egui-ash")),
            ..Default::default()
        },
    )
}

Full example is in examples directory

Feature flags

  • gpu-allocator - Enables the gpu-allocator crate.
  • persistence - Enables the persistence feature of egui.

The other features directly control the underlying egui_winit features

License

MIT OR Apache-2.0

You might also like...
Render egui with skia!

Skia backend for egui This is a drawing backend for egui that uses skia-safe. Usage Have a look at the metal or cpu examples to get started. Run the e

a day-planner/calendar app based on egui
a day-planner/calendar app based on egui

Malakal Malakal is a day planner application. I crafted it because I was not able to find a comfortable calendar application for Linux. I myself have

Example showing how to use tokio and egui together.

Example using tokio with egui This example uses reqwest to send an HTTP request to httpbin. The parsed response contains an increment value (as provid

A render-backend independant egui backend for sdl2

A Sdl2 + Egui Backend An egui backend for sdl2 unbound to any renderer-backend. You can include it like so: [dependencies] egui_sdl2_platform = "0.1.0

egui backend for D3D9.

egui-d3d9 egui backend for D3D9. Primarily intended for source games like CS:GO and GMod. It's not perfect by far, but it'll do. This is a rewrite of

A tool for creating egui Visuals (themes).

egui-visuals-utility A tool for creating egui Visuals (themes). The code is rather messy and might crash but it seems to work. To load the theme use s

egui port to Car Thing (and maybe an alternative Car Thing UI?)
egui port to Car Thing (and maybe an alternative Car Thing UI?)

tt This project contains a port of egui to the Spotify Car Thing although in the future I also plan for it to contain a custom Car Thing UI. Technical

Create dynamic grid-based layouts for egui

egui_grid Create dynamic grid layouts for egui. Grids are flexible, easy to create, with behavior similar to egui_extra's strip creation. They're comp

Provides event handling for egui in SDL2 window applications.

egui-sdl2-event Provides event handling for egui when SDL2 is used as the windowing system. This crate does not perform any rendering, but it can be c

Owner
Orito Itsuki
I'm a heavy user of Google Translate!
Orito Itsuki
Egui node graph is a featureful, customizable library to create node graph applications using egui

Egui node graph is a featureful, customizable library to create node graph applications using egui. The library takes care of presenting a node graph to your users, and allows customizing many aspects of the interaction, creating the semantics you want for your specific application.

null 367 Jan 8, 2023
A presentation about egui, implemented in egui

egui presentation A presentation about egui, implemented in egui. You can view the presentation at https://emilk.github.io/egui_presentation/. TODO Li

Emil Ernerfeldt 9 Aug 24, 2023
A react-inspired UI library for building multimedia desktop apps with rust and vulkan.

narui A react-inspired UI library for building multimedia desktop apps with rust and vulkan. declarative UI with Ergonomics similar to React with hook

apertusĀ° - open source cinema 42 Jan 1, 2023
This project attempts to allow the creation of reusable egui-themes

egui stylist Note this project is considered to be experimental and -- while used in personal projects -- may have API breaking changes without warnin

Jacobsky 22 Dec 1, 2022
A simple GUI version of the pH calibration tool written in egui, based on the eframe template.

caliphui A simple GUI version of the pH calibration tool written in egui, based on the eframe template. Usage Native binaries are provided under relea

Peter Dunne 0 Dec 29, 2021
FLTK frontend for Egui WGPU backend.

Egui FLTK Frontend FLTK Frontend for Egui WGPU Backend On linux Debian/Ubuntu, make sure to install the latest main requirements: sudo apt-get update

Adia Robbie 5 Oct 25, 2022
egui: an easy-to-use immediate mode GUI in pure Rust

?? egui: an easy-to-use GUI in pure Rust egui is a simple, fast, and highly portable immediate mode GUI library for Rust. egui runs on the web, native

Emil Ernerfeldt 12.6k Jan 3, 2023
D3D11 backend for egui library. Presumably for mods/cheats development

D3D11 backend for egui library. Presumably for mods/cheats development. Currently few features from egui are missing. WIP.

sy1ntexx 24 Jan 4, 2023
Egui bindings for macroquad

egui bindings for macroquad This is the easiest way to use egui. Just two functions! Web demo. Usage You need to call ui when you need to get informat

ilya sheprut 54 Dec 28, 2022
Egui bindings for miniquad

egui bindings for miniquad native On Linux you first must run apt install libx11-dev libxi-dev libgl1-mesa-dev (miniquad dependencies). cargo run --re

Fedor Logachev 48 Dec 28, 2022