Expand description
Public hook for user widgets to inject their own wgpu render pass(es) into the agg-gui frame.
§Why
agg-gui paints 2-D widgets via deferred DrawCommands that flush into a
single wgpu::CommandEncoder in WgpuGfxCtx::end_frame. A
3-D viewport widget (e.g. AtomArtist’s Viewport3dWidget) needs to run
its own render pass(es) interleaved with that 2-D stream so its output
ends up on the same surface or layer texture, with depth-correct
ordering relative to surrounding 2-D content.
The demo’s own WgpuCubeWidget used to push a hard-coded
DrawCommand::DrawBarGrid variant directly into the command list — which
worked but was not extensible, and it kept demo content inside the
renderer. This module generalises that pattern so any widget can plug in;
the cube now rides this path like everyone else.
§How to use
- Define a struct that implements
WgpuCustomRender. - Hold it in
Rc<RefCell<dyn WgpuCustomRender>>so the widget can keep a clone (lazy-init / persistent buffers across frames). - From your widget’s
paint(ctx), downcastctxtoWgpuGfxCtxviaDrawCtx::as_any_mutand callWgpuGfxCtx::push_custom_render.
§Pass semantics
When the executor reaches a DrawCommand::Custom entry, it:
- Ends the active 2-D render pass.
- Calls
WgpuCustomRender::renderwith aWgpuCustomRenderCtxpointing at the same encoder + active target view. - Reopens a 2-D pass with
LoadOp::Loadso subsequent 2-D content composites cleanly on top.
The custom renderer may record any number of its own passes against
the encoder, including offscreen passes followed by a blit to
target_view. Conventionally the implementor should leave its target
state untouched after returning (no in-progress pass, no orphaned
buffer mappings).
Structs§
- Wgpu
Custom Render Ctx - Inputs handed to a
WgpuCustomRenderimplementor at execution time.
Traits§
- Wgpu
Custom Render - Trait implemented by widgets that want to inject custom wgpu render commands into the frame.
Type Aliases§
- Shared
Custom Renderer - Convenience type alias for the boxed-trait pattern most callers use.