Skip to main content

euv_engine/engine/
struct.rs

1use crate::*;
2
3/// A zero-sized namespace struct providing static engine entry points.
4///
5/// This struct follows the same pattern as `euv::App`, serving as the
6/// single root namespace for all top-level engine operations: creating
7/// engine handles, initializing rendering backends, and starting the
8/// fixed-timestep game loop.
9///
10/// All engine usage flows through `Engine::xxx` static calls, mirroring
11/// how `euv::App::use_signal` / `euv::App::mount` are the public entry
12/// points of the core framework.
13#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
14pub struct Engine;
15
16/// A handle to a running or initialized engine instance.
17///
18/// Holds the engine configuration, an optional Canvas 2D renderer, an
19/// optional WebGPU renderer, and the optional scheduler handle once the
20/// game loop has started. Use `Engine::new_handle` to construct one, then
21/// call `init_canvas` or `init_webgpu` (matching the backend chosen in
22/// `RenderConfig`) and finally `start` to begin the game loop.
23#[derive(Clone, Data, New)]
24pub struct EngineHandle {
25    /// The engine configuration containing render and scheduler settings.
26    pub(crate) config: EngineConfig,
27    /// The initialized Canvas 2D renderer, or `None` if the WebGPU backend is used or initialization has not yet happened.
28    pub(crate) canvas_renderer: Option<CanvasRenderer>,
29    /// The initialized WebGPU renderer, or `None` if the Canvas 2D backend is used or initialization has not yet happened.
30    pub(crate) webgpu_renderer: Option<WebGpuRenderer>,
31    /// The running scheduler handle, or `None` before `start` is called.
32    pub(crate) scheduler_handle: Option<SchedulerHandle>,
33}