astrelis_winit/lib.rs
1//! Window and event management for Astrelis engine.
2//!
3//! This crate provides the [`App`] trait for game loop implementation,
4//! window creation/management, and event batching for efficient processing.
5//!
6//! # Quick Start
7//!
8//! ```rust,no_run
9//! use astrelis_winit::{app::{run_app, App, AppCtx}, FrameTime, WindowId, event::EventBatch};
10//!
11//! struct MyApp;
12//!
13//! impl App for MyApp {
14//! fn update(&mut self, _ctx: &mut AppCtx, _time: &FrameTime) {
15//! // Game logic update
16//! }
17//!
18//! fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
19//! // Rendering logic per window
20//! }
21//! }
22//!
23//! fn main() {
24//! run_app(|_ctx| Box::new(MyApp));
25//! }
26//! ```
27//!
28//! # App Lifecycle
29//!
30//! Methods are called in this order each frame:
31//! 1. [`App::on_start()`] - Once at startup
32//! 2. [`App::begin_frame()`] - Start of each frame
33//! 3. [`App::update()`] - Game logic update
34//! 4. [`App::fixed_update()`] - Physics/fixed timestep (repeated as needed)
35//! 5. [`App::render()`] - Per-window rendering (called for each window)
36//! 6. [`App::end_frame()`] - End of each frame
37//! 7. [`App::on_exit()`] - Once at shutdown
38//!
39//! # Event Batching
40//!
41//! Events are collected and batched per-window using [`EventBatch`]. Access events
42//! in the `render()` method to handle input for each window separately.
43//!
44//! # Features
45//!
46//! - Window creation and management via [`window::WindowBackend`]
47//! - Event loop integration with winit
48//! - Frame timing and fixed timestep support via [`FrameTime`]
49//! - Window resizing, focus, and lifecycle events
50//!
51//! [`App`]: app::App
52//! [`App::on_start()`]: app::App::on_start
53//! [`App::begin_frame()`]: app::App::begin_frame
54//! [`App::update()`]: app::App::update
55//! [`App::fixed_update()`]: app::App::fixed_update
56//! [`App::render()`]: app::App::render
57//! [`App::end_frame()`]: app::App::end_frame
58//! [`App::on_exit()`]: app::App::on_exit
59//! [`EventBatch`]: event::EventBatch
60
61pub mod app;
62pub mod event;
63pub mod time;
64pub mod window;
65
66// Re-export WindowId for convenience
67pub use winit::window::WindowId;
68
69// Re-export FrameTime for convenience
70pub use time::FrameTime;