Draw dear imgui UIs as a wgpu render pass. Based on imgui-gfx-renderer from imgui-rs.
use imgui_wgpu::Renderer;
let device: wgpu::Device = ..;
let imgui: imgui::ImGui = ..;
let format = wgpu::TextureFormat::Bgra8Unorm;
let clear_color = wgpu::Color { r: 0.1, g: 0.2, b: 0.3, a: 1.0 };
let mut renderer = Renderer::new(&mut imgui, &mut device, format, Some(clear_color))
.expect("Failed to initialize renderer");
let device: wgpu::Device = ..;
let imgui: imgui::ImGui = ..;
let swap_chain: wgpu::SwapChain = ..;
let mut encoder: wgpu::CommandEncoder = ..;
let ui = imgui.frame(..);
let frame = swap_chain.get_next_texture();
renderer
.render(ui, &mut device, &mut encoder, &frame.view)
.expect("Rendering failed");
For usage:
cargo run --example hello_world --features [vulkan|metal|dx12]
Work in progress.
Known issues:
Contributions welcome.