Skip to main content

Crate imgui_wgpu

Crate imgui_wgpu 

Source
Expand description

§imgui-wgpu

A wgpu render backend for imgui-rs.

§Quick Start

// During setup:
let mut imgui = Context::create();
let renderer_config = RendererConfig {
    texture_format: surface_format,
    ..RendererConfig::new()
};
let mut renderer = Renderer::new(&mut imgui, &device, &queue, renderer_config);

// Each frame:
// let draw_data = imgui_context.render();
// let mut rpass = encoder.begin_render_pass(&render_pass_desc);
// renderer.render(draw_data, &queue, &device, &mut rpass).unwrap();

§Color Space

The default RendererConfig::new outputs linear color, appropriate for sRGB framebuffers (e.g. Bgra8UnormSrgb). If you are rendering to a linear framebuffer (e.g. Bgra8Unorm), use RendererConfig::new_srgb instead.

§Custom Textures

Create a Texture, then insert it into Renderer::textures to get a imgui::TextureId for use with imgui image widgets:

let config = TextureConfig {
    size: wgpu::Extent3d { width: 64, height: 64, depth_or_array_layers: 1 },
    ..Default::default()
};
let texture = Texture::new(&device, &renderer, config);
texture.write(&queue, &pixel_data, 64, 64);
let tex_id = renderer.textures.insert(texture);

§Split Rendering

For more control over buffer lifetime, use Renderer::prepare and Renderer::split_render separately instead of Renderer::render. This lets you reuse RenderData across frames and control when GPU buffers are created.

Structs§

RawTextureConfig
Config for creating a texture from raw parts
RenderData
Intermediate render state produced by Renderer::prepare and consumed by Renderer::split_render.
Renderer
The main imgui-wgpu renderer.
RendererConfig
Configuration for the Renderer.
Texture
A container for a bindable texture.
TextureConfig
Config for creating a texture.

Enums§

RendererError
Errors that can occur during rendering.

Type Aliases§

RendererResult
Result type for renderer operations.