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
//! winit integration: presenting a renderer, and driving callbacks as behaviours.
//!
//! Three layers, each with one job:
//!
//! - [`surface`] presents a [`Renderer`](crate::renderer::Renderer) into a
//! window. It owns the swap chain and its configuration; the caller's frame
//! loop is acquire, bind, render, present.
//! - [`event`] bridges winit's callbacks to the world. Every
//! [`ApplicationHandler`](winit::application::ApplicationHandler) callback
//! has a behaviour component family, and [`event::WinitHost`] is the one
//! `ApplicationHandler` that dispatches to them. It holds no application
//! logic of its own.
//! - [`builtin`] is the common lifecycle behaviour built on top of the bridge:
//! create the window on resume, exit on close, feed input, request redraws.
//!
//! A callback is an ordinary behaviour component, so an application composes
//! it the way it composes every other behaviour: spawn it on an entity, and
//! the host drives it. Nothing built in has a path an application cannot take.
//!
//! # A windowed application
//!
//! ```rust,no_run
//! use unlit3d::prelude::*;
//! use unlit3d::winit::builtin::{ExitOn, ExitTrigger, WindowSetup};
//! use unlit3d::winit::event::WinitHost;
//! use winit::event_loop::EventLoop;
//! use winit::window::Window;
//!
//! # fn main() -> Result<(), winit::error::EventLoopError> {
//! let event_loop = EventLoop::new()?;
//! let mut host = WinitHost::new();
//! host.world_mut().root_scope_mut().spawn(WindowSetup {
//! attributes: Window::default_attributes().with_title("unlit3d"),
//! });
//! host.world_mut()
//! .root_scope_mut()
//! .spawn(ExitOn(ExitTrigger::CloseRequested));
//! host.run(event_loop)
//! # }
//! ```
pub use ;