Skip to main content

euv_engine/config/
struct.rs

1use super::*;
2
3/// Rendering configuration controlling the backend type, canvas target,
4/// viewport dimensions, quality, and backend-specific options.
5///
6/// Passed as part of `EngineConfig` when instantiating the engine.
7#[derive(Clone, Data, Debug, New, PartialEq)]
8pub struct RenderConfig {
9    /// The rendering backend to use (Canvas 2D or WebGPU).
10    #[get(type(copy))]
11    #[get_mut(pub(crate))]
12    #[set(pub(crate))]
13    pub(crate) backend: RenderBackendType,
14    /// The CSS selector used to query the canvas element from the DOM.
15    #[get(type(clone))]
16    #[get_mut(pub(crate))]
17    #[set(pub(crate))]
18    pub(crate) canvas_selector: String,
19    /// The logical viewport width in CSS pixels.
20    #[get(type(copy))]
21    #[get_mut(pub(crate))]
22    pub(crate) width: f64,
23    /// The logical viewport height in CSS pixels.
24    #[get(type(copy))]
25    #[get_mut(pub(crate))]
26    pub(crate) height: f64,
27    /// The rendering quality preset for canvas smoothing and SSAA downscaling.
28    #[get(type(copy))]
29    #[new(skip)]
30    #[get(pub(crate))]
31    #[get_mut(pub(crate))]
32    #[set(pub(crate))]
33    pub(crate) quality: RenderQuality,
34    /// Whether MSAA anti-aliasing is enabled for the WebGPU backend.
35    ///
36    /// Ignored when `backend` is `Canvas2D`.
37    #[get(type(copy))]
38    #[new(skip)]
39    #[get_mut(pub(crate))]
40    #[set(pub(crate))]
41    pub(crate) antialias: bool,
42    /// The power preference hint for WebGPU adapter selection.
43    ///
44    /// Ignored when `backend` is `Canvas2D`.
45    #[get(type(copy))]
46    #[new(skip)]
47    #[get(pub(crate))]
48    #[get_mut(pub(crate))]
49    #[set(pub(crate))]
50    pub(crate) power_preference: GpuPowerPreference,
51    /// The SSAA supersampling scale factor for the Canvas 2D backend.
52    ///
53    /// A value of 2.0 renders at 4x resolution and downscales for smoother
54    /// edges. Ignored when `backend` is `WebGpu`.
55    #[get(type(copy))]
56    #[new(skip)]
57    #[get_mut(pub(crate))]
58    #[set(pub(crate))]
59    pub(crate) ssaa_scale_factor: f64,
60}
61
62/// The top-level engine configuration containing rendering and scheduler settings.
63///
64/// Passed to `Engine::new` to configure the engine instance.
65#[derive(Clone, Data, Debug, New, PartialEq)]
66pub struct EngineConfig {
67    /// The rendering configuration.
68    #[get(type(clone))]
69    #[get_mut(pub(crate))]
70    #[set(pub(crate))]
71    pub(crate) render: RenderConfig,
72    /// The scheduler configuration controlling the fixed-timestep game loop.
73    #[get(type(copy))]
74    #[new(skip)]
75    #[get_mut(pub(crate))]
76    #[set(pub(crate))]
77    pub(crate) scheduler: SchedulerConfig,
78}