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
//! A shared layer for window-based backends (software, GL, wgpu).
//!
//! # Architecture
//!
//! [`Backend`](retroglyph_core::Backend) fuses input (`poll_event`/
//! `push_event`) and output (`draw_layers`/`flush`/...), which fits a
//! terminal process but not a window: there, an event loop owns input and a
//! renderer owns output. This crate splits the two apart and reassembles
//! them into one `Backend`:
//!
//! ```text
//! ┌─────────────────────────────┐
//! │ event loop (winit or │
//! │ a custom driver) │
//! └──────────────┬───────────────┘
//! translated events
//! │
//! v
//! ┌────────────────────────────────────────────────────┐
//! │ WindowBackend<P: Presenter> │
//! │ (implements Backend: owns the input event queue, │
//! │ delegates output to P) │
//! └───────────────────────┬──────────────────────────────┘
//! │ draw / flush / resize / present
//! v
//! ┌───────────────────────────────┐
//! │ P: Presenter │
//! │ (retroglyph-software today; │
//! │ wgpu/GL renderers planned) │
//! └───────────────────────────────┘
//! ```
//!
//! - [`Presenter`] is the output half: rasterization plus the surface
//! lifecycle (`init_surface`/`resize_surface`/`present`/`cell_size`).
//! Renderer crates implement only this trait.
//! - <code>[WindowBackend]<P: Presenter></code> implements `Backend`
//! generically, holding the input event queue and delegating output to
//! `P`.
//! - The `winit` module (feature-gated, see below) drives the event loop
//! that fills that queue and calls `Presenter::present` each frame.
//!
//! # Feature flags
//!
//! [`Presenter`], [`WindowBackend`], and [`WindowHandle`] depend only on
//! [`raw-window-handle`](raw_window_handle) and are always available. The
//! `winit` feature (default on) additionally provides the `winit` module:
//! the event loop, event translation, and the `run_windowed`/`run_app`
//! drivers. Disable it to implement or drive `Presenter` with a different
//! windowing library (SDL2, tao, a custom loop) without pulling in winit.
/// The generic [`Backend`](retroglyph_core::Backend) for windowed presenters.
/// The [`Presenter`] trait and [`WindowHandle`](presenter::WindowHandle).
/// The winit event loop, event translation, and app drivers.
pub use WindowBackend;
pub use ;
// Re-exported so presenters can name the handle traits without adding their
// own raw-window-handle dependency (and so versions can't drift apart).
pub use raw_window_handle;