Expand description
Custom render command extension point for the wgpu backend.
Implement WgpuDrawable on types not covered by crate::default_drawables.
Custom drawables receive a WgpuDrawContext with access to the frame’s geometry batch,
text state, scissor region, depth ordering, and DPI scale.
§Examples
ⓘ
use cotis_wgpu::drawable::{WgpuDrawable, WgpuDrawContext};
use cotis_wgpu::pipeline::{UIColor, UIPosition, UICornerRadii};
struct RedSquare;
impl WgpuDrawable for RedSquare {
fn draw(self: Box<Self>, ctx: &mut WgpuDrawContext<'_>) {
ctx.geometry.filled_rectangle(
UIPosition { x: 10.0, y: 10.0, z: *ctx.depth },
UIPosition { x: 100.0, y: 100.0, z: *ctx.depth },
UIColor { r: 1.0, g: 0.0, b: 0.0 },
UICornerRadii {
top_left: 0.0,
top_right: 0.0,
bottom_left: 0.0,
bottom_right: 0.0,
},
);
*ctx.depth -= 0.000_1;
}
}Structs§
- Wgpu
Draw Context - Per-frame drawing context passed to each
WgpuDrawablecommand.
Traits§
- Wgpu
Drawable - A render command that can be executed against the wgpu backend.