Skip to main content

Crate dear_imgui_wgpu

Crate dear_imgui_wgpu 

Source
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-29
    • wgpu-28
    • wgpu-27 (for ecosystems pinned to wgpu 27.x, e.g. some Bevy version trains)
  • Diagnostics: tracing emits 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::TextureView handles 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-winit for winit or multi-viewport-sdl3 for 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§

ExternalTextureId
Opaque handle for an application-owned WGPU texture view registered with a renderer.
FramebufferExtent
Physical dimensions of the WGPU render target receiving Dear ImGui commands.
WgpuInitInfo
Initialization data for ImGui WGPU renderer.
WgpuRenderState
Scoped access to the WGPU resources selected for a raw draw callback.
WgpuRenderer
Main WGPU renderer for Dear ImGui
WgpuViewportSurfaceConfig
Presentation policy for WGPU surfaces created for secondary viewports.

Enums§

GammaMode
Gamma correction mode for the WGPU renderer
RendererError
Errors that can occur during rendering operations
WgpuRenderStateAccessError
Error returned while borrowing the transient WGPU draw-callback state.

Type Aliases§

RendererResult
Result type for renderer operations