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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//! wgpu-backed desktop renderer for the [Cotis](https://crates.io/crates/cotis) UI ecosystem.
//!
//! `cotis-wgpu` implements Cotis's [`cotis::renders::CotisRenderer`] and
//! [`cotis::renders::CotisRendererAsync`] traits on top of [wgpu](https://crates.io/crates/wgpu) 24,
//! [winit](https://crates.io/crates/winit) 0.30, and [glyphon](https://crates.io/crates/glyphon) 0.8.
//! It is a drop-in alternative to other Cotis render backends such as `cotis-raylib`.
//!
//! # Quick start
//!
//! For interactive applications, create a [`CotisWgpuRenderer`] and wire it into
//! [`CotisApp`](cotis::cotis_app::CotisApp) (from `cotis::cotis_app`) with a layout manager and pipe:
//!
//! ```rust,ignore
//! use cotis::cotis_app::{CotisApp, RenderApp};
//! use cotis_layout::preamble::CotisLayoutManager;
//! use cotis_pipes::cotis_layout_pipes::CotisLayoutToRenderListPipeForGenerics;
//! use cotis_utils::math::Dimensions;
//! use cotis_wgpu::prelude::*;
//!
//! let renderer = CotisWgpuRenderer::auto_start();
//! let manager = CotisLayoutManager::new(Dimensions::new(1000.0, 800.0));
//! let mut app = CotisApp::new(renderer, manager, CotisLayoutToRenderListPipeForGenerics);
//!
//! while !app.render().window_should_close() {
//! RenderApp::compute_frame(&mut app, |root| {
//! // build UI on root
//! });
//! }
//! ```
//!
//! For the full wiring pattern including a `StandardRenderCmds` type alias, see
//! `examples/basic_example/support.rs` in this crate's source tree.
//!
//! Run the shipped example from the workspace root:
//!
//! ```text
//! cargo run --example basic_example -p cotis-wgpu
//! ```
//!
//! # Recommended imports
//!
//! Use [`prelude`] for the common entry-point types:
//!
//! ```rust,no_run
//! use cotis_wgpu::prelude::*;
//! ```
//!
//! # Rendering model
//!
//! [`CotisWgpuRenderer`] draws three kinds of command streams:
//!
//! - [`cotis_defaults::render_commands::render_t_list::RenderTList`] with a nested list type —
//! typed heterogeneous command lists produced by layout pipes (primary path with `cotis-pipes`).
//! - [`cotis_defaults::render_commands::render_t_list::RenderTList`] with `()` as the list tail —
//! single-command lists.
//! - [`Box<dyn drawable::WgpuDrawable>`] — type-erased custom commands; implement
//! [`drawable::WgpuDrawable`] for types not covered by `cotis-defaults` commands.
//!
//! Each [`cotis::renders::CotisRenderer::draw_frame`] call pumps the winit event loop before presenting.
//! [`CotisWgpuRenderer::window_should_close`] also pumps events, so the typical app loop calls
//! `app.render()` (which invokes `draw_frame`) and then checks `window_should_close()`.
//!
//! Built-in drawing for standard `cotis-defaults` commands lives in [`default_drawables`].
//! Custom commands can use the advanced [`pipeline`], [`surface`], and [`text`] modules directly.
//!
//! # Cotis trait implementations
//!
//! [`CotisWgpuRenderer`] also implements Cotis context and interactivity traits.
//! See [`cotis_traits`] for the full list, including:
//!
//! - [`cotis_utils::traits::CotisWindowContext`] — physical window dimensions in pixels.
//! - [`cotis_utils::traits::CotisFrameContext`] — frame delta time.
//! - [`cotis_utils::traits::CotisRenderContext`] — render marker trait.
//! - [`cotis_utils::text::RendererTextMeasuringProvider`] — glyphon text measurement.
//! - [`cotis_utils::interactivity::mouse::MouseProvider`] and keyboard providers via [`input`].
//!
//! # Features
//!
//! | Feature | Effect |
//! |---------|--------|
//! | `complex-color` | Enables `cotis-defaults/complex_color` and `complex_colored_text`. Accepts `ColorLayer` types but **does not render gradients** — see [`default_drawables`]. |
//!
//! # Known limitations
//!
//! - **Fonts:** All text uses glyphon `Family::SansSerif`. `TextConfig::font_id` is ignored; there is
//! no font-loading API.
//! - **Images:** [`cotis_defaults::render_commands::Image`] commands render as colored rectangles;
//! texture loading is not implemented.
//! - **Geometry alpha:** The UI shader outputs opaque fragments; cotis color alpha is ignored for
//! rectangles and borders (text alpha is preserved via glyphon).
//! - **Async renderer:** [`cotis::renders::CotisRendererAsync`] delegates synchronously to
//! [`cotis::renders::CotisRenderer`]; there is no async GPU work.
//! - **Frame errors:** Present failures log a warning and skip the frame; the application continues.
//!
//! # Public modules
//!
//! | Module | Role |
//! |--------|------|
//! | [`prelude`] | Application entry-point re-exports |
//! | [`renderer`] | [`CotisWgpuRenderer`], [`WindowConfig`], event loop |
//! | [`error`] | [`WgpuBackendError`] |
//! | [`drawable`] | [`drawable::WgpuDrawable`] extension trait |
//! | [`default_drawables`] | Built-in `WgpuDrawable` impls for `cotis-defaults` commands |
//! | [`cotis_traits`] | Cotis context/interactivity trait impls |
//! | [`color`] | Cotis `Color` → wgpu conversions |
//! | [`input`] | winit input snapshot |
//! | [`pipeline`] | Advanced: UI geometry batch and WGSL pipeline |
//! | [`surface`] | Advanced: swapchain and depth buffer |
//! | [`text`] | Advanced: glyphon text batching |
pub use WgpuBackendError;
pub use ;
/// Convenient re-exports for application code.
///
/// Typical import:
///
/// ```rust,no_run
/// use cotis_wgpu::prelude::*;
/// ```