1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! 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
//!
//! ```rust,ignore
//! 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;
//! }
//! }
//! ```
use crateGeometryBatch;
use crateUIPosition;
use crateTextState;
/// Per-frame drawing context passed to each [`WgpuDrawable`] command.
/// A render command that can be executed against the wgpu backend.
///
/// Commands are consumed as `Box<Self>` and executed during frame presentation.
/// See [`crate::default_drawables`] for built-in implementations of standard
/// `cotis-defaults` command types.