Expand description
WGPU backend for Dear ImGui
This crate provides a WGPU-based renderer for Dear ImGui, allowing you to render Dear ImGui interfaces using the WGPU graphics API.
§Features
- WGPU version selection: choose exactly one of:
wgpu-30(default)wgpu-29wgpu-28wgpu-27(for ecosystems pinned to wgpu 27.x, e.g. some Bevy version trains)
- Diagnostics:
tracingemits renderer debug and warning events and is off by default - Managed textures: pointer-free create/update/destroy requests owned by rendered frames
- External textures: Register application-owned
wgpu::TextureViewhandles for UI display - Gamma correction: Automatic sRGB format detection and gamma correction
- Epoch-isolated uploads: Vertex, index, and uniform buffers are never reused across render epochs
- Device object management: Helpers to recreate device objects (pipelines/buffers/textures) after loss
- Multi-viewport support: Support for multiple windows (feature-gated via
multi-viewport-winitfor winit ormulti-viewport-sdl3for SDL3 on native targets)
§Example
use dear_imgui_rs::Context;
use dear_imgui_wgpu::{FramebufferExtent, WgpuInitInfo, WgpuRenderer, wgpu};
// Create Dear ImGui context
let mut imgui = Context::create();
// Create renderer (recommended path)
let init_info = WgpuInitInfo::new(device, queue, wgpu::TextureFormat::Bgra8UnormSrgb);
let mut renderer = WgpuRenderer::new(init_info, &mut imgui)?;
// In your render loop:
// imgui.new_frame();
// ... build your UI ...
// let frame = imgui.render(renderer.renderer_consumer()?);
// let extent = FramebufferExtent::from_texture(&surface_texture.texture);
// renderer.render(frame, &mut render_pass, extent)?;Re-exports§
pub extern crate wgpu30 as wgpu;
Structs§
- External
Texture Id - Opaque handle for an application-owned WGPU texture view registered with a renderer.
- Framebuffer
Extent - Physical dimensions of the WGPU render target receiving Dear ImGui commands.
- Wgpu
Init Info - Initialization data for ImGui WGPU renderer.
- Wgpu
Render State - Scoped access to the WGPU resources selected for a raw draw callback.
- Wgpu
Renderer - Main WGPU renderer for Dear ImGui
- Wgpu
Viewport Surface Config - Presentation policy for WGPU surfaces created for secondary viewports.
Enums§
- Gamma
Mode - Gamma correction mode for the WGPU renderer
- Renderer
Error - Errors that can occur during rendering operations
- Wgpu
Render State Access Error - Error returned while borrowing the transient WGPU draw-callback state.
Type Aliases§
- Renderer
Result - Result type for renderer operations