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§
- RawTexture
Config - Config for creating a texture from raw parts
- Render
Data - Intermediate render state produced by
Renderer::prepareand consumed byRenderer::split_render. - Renderer
- The main imgui-wgpu renderer.
- Renderer
Config - Configuration for the
Renderer. - Texture
- A container for a bindable texture.
- Texture
Config - Config for creating a texture.
Enums§
- Renderer
Error - Errors that can occur during rendering.
Type Aliases§
- Renderer
Result - Result type for renderer operations.