//! Windowing and the application event loop. //! //! Stage 2 scope: open a window via `winit`, hand its surface to the //! [`render`](crate::render) module, and run a clear-color render loop. //! Applications implement [`WindowApp`] and are driven by [`run`]; raw window //! events (keyboard, mouse, resize, …) are forwarded to //! [`WindowApp::event`] untranslated — input abstraction arrives in Stage 5. //! //! Stage 6 renamed this trait from `App` to `WindowApp` so the engine's core //! [`App`](crate::app::App) container — the owner of scene, assets, and //! scheduled systems — can live in the prelude unambiguously. The two are //! distinct roles: this trait is the **window-event handler** the editor and //! examples implement; the core `App` is the engine state they typically wrap //! around. mod app; mod runner; pub use app::{AppCtx, RenderCtx, WindowApp}; pub use runner::run; pub mod event { //! Raw window/input event types, re-exported from `winit`. //! //! Stage 2 deliberately exposes events untranslated; the Stage 5 input //! system will layer action mapping on top of these. pub use winit::dpi::{PhysicalPosition, PhysicalSize}; pub use winit::event::{ DeviceEvent, DeviceId, ElementState, KeyEvent, Modifiers, MouseButton, MouseScrollDelta, WindowEvent, }; pub use winit::keyboard::{Key, KeyCode, ModifiersState, NamedKey, PhysicalKey}; } use crate::math::Color; /// Initial window settings, consumed by [`run`]. #[derive(Debug, Clone)] pub struct WindowConfig { /// Window title. pub title: String, /// Initial inner width in logical pixels. pub width: u32, /// Initial inner height in logical pixels. pub height: u32, /// Whether the user can resize the window. pub resizable: bool, /// Color the surface is cleared to each frame (changeable at runtime via /// [`AppCtx::set_clear_color`]). pub clear_color: Color, } impl Default for WindowConfig { fn default() -> Self { Self { title: "Oxide".to_string(), width: 1280, height: 720, resizable: true, clear_color: Color::BLACK, } } }