Crates.io | imgui-vulkano-renderer-unsafe |
lib.rs | imgui-vulkano-renderer-unsafe |
version | 0.6.1 |
source | src |
created_at | 2021-02-02 20:27:55.54134 |
updated_at | 2021-02-22 22:44:17.990445 |
description | A renderer for imgui-rs using Vulkano that also works with UnsafeCommandBufferBuilder |
homepage | |
repository | https://gitlab.com/pac85/imgui-vulkano-renderer.git |
max_upload_size | |
id | 349884 |
size | 1,909,067 |
A vulkano-based renderer for imgui-rs.
Warning: I've only used this renderer in a few examples and a couple projects, so there are likely some issues, but it seems to work with basic ImGui usage.
Supports imgui-rs version 0.6.0
and vulkano version 0.19.0
.
Note: Currently vulkano-win
, the vulkano winit
integration, only supports winit 0.22.2
while imgui-winit-support
by default uses winit 0.23.0
. To make them compatible, enable the winit-22
feature in the imgui-winit-support
crate.
The Renderer
struct is designed to be a drop-in replacement for the equivalent in imgui-glium-renderer
and imgui-gfx-renderer
(from the imgui-rs repository), modulo the API-specific context arguments (the Vulkano Device
and Queue
structs).
use imgui_vulkano_renderer::Renderer;
let mut renderer = Renderer::init(
&mut imgui_ctx,
device.clone(),
graphics_queue.clone(),
Format::R8G8B8A8Srgb
).unwrap();
Use the Renderer::draw_commands
function to update buffers and
let ui = imgui_ctx.frame();
// ... UI elements created here
let draw_data = ui.render();
let mut cmd_buf_builder = AutoCommandBufferBuilder::new(device.clone(), graphics_queue.family()).unwrap();
// add Vulkan commands to a command buffer. Here a new command buffer is used, but you can also append to an existing one.
renderer.draw_commands(&mut cmd_buf_builder, graphics_queue.clone(), target_image.clone(), draw_data).unwrap();
let cmd_buf = cmd_buf_builder.build().unwrap();
The font altas texture are reloaded with the following:
renderer.reupload_font_texture(&mut imgui_ctx, device.clone(), queue.clone());
Textures used in your UI are looked up in an imgui::Textures
struct, which can be accessed with Renderer::textures
.
I rewrote a couple of examples from imgui-rs to show basic usage (most of them only needed setup changes to the System
struct in examples/support/mod.rs
). They can be run with:
cargo run --example hello_world
cargo run --example custom_textures