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
- Modern texture management: Full integration with Dear ImGui’s ImTextureData system
- Gamma correction: Automatic sRGB format detection and gamma correction
- Multi-frame buffering: Support for multiple frames in flight
- Device object management: Proper handling of device loss and recovery
- Multi-viewport support: Support for multiple windows (feature-gated)
§Example
use dear_imgui::Context;
use dear_imgui_wgpu::{WgpuRenderer, WgpuInitInfo};
use wgpu::*;
// Initialize WGPU device and queue
let instance = Instance::new(&InstanceDescriptor::default());
let adapter = instance.request_adapter(&RequestAdapterOptions::default()).await.unwrap();
let (device, queue) = adapter.request_device(&DeviceDescriptor::default()).await?;
// Create Dear ImGui context
let mut imgui = Context::create();
// Create renderer
let init_info = WgpuInitInfo::new(device, queue, TextureFormat::Bgra8UnormSrgb);
let mut renderer = WgpuRenderer::new();
renderer.init(init_info)?;
renderer.configure_imgui_context(&mut imgui);
renderer.prepare_font_atlas(&mut imgui)?;
// In your render loop:
// imgui.new_frame();
// ... build your UI ...
// let draw_data = imgui.render();
// renderer.render_draw_data(&draw_data, &mut render_pass)?;Structs§
- Frame
Resources - Per-frame resources
- Frame
Resources Stats - Statistics for frame resources
- Render
Resources - Shared render resources
- Render
Resources Stats - Statistics for render resources
- Shader
Manager - Shader manager
- Uniform
Buffer - Uniform buffer manager
- Uniforms
- Uniform data structure
- Wgpu
Backend Data - Main backend data structure
- Wgpu
Init Info - Initialization data for ImGui WGPU renderer
- Wgpu
Render State - Selected render state data shared with callbacks
- Wgpu
Renderer - Main WGPU renderer for Dear ImGui
- Wgpu
Texture - WGPU texture resource
- Wgpu
Texture Manager - Texture manager for WGPU renderer
Enums§
- Gamma
Mode - Gamma correction mode for the WGPU renderer
- Renderer
Error - Errors that can occur during rendering operations
- Texture
Update Result - Result of a texture update operation
Constants§
- FS_
ENTRY_ POINT - Fragment shader entry point
- SHADER_
SOURCE - WGSL shader source
- VS_
ENTRY_ POINT - Vertex shader entry point
Functions§
- create_
bind_ group_ layouts - Create bind group layouts for the pipeline
- create_
fragment_ state - Create fragment state for render pipeline
- create_
vertex_ buffer_ layout - Create vertex buffer layout for Dear ImGui vertices
- create_
vertex_ state - Create vertex state for render pipeline
Type Aliases§
- Renderer
Result - Result type for renderer operations