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 pub(crate) backend: RenderBackendType,
12 /// The CSS selector used to query the canvas element from the DOM.
13 #[get(type(clone))]
14 pub(crate) canvas_selector: String,
15 /// The logical viewport width in CSS pixels.
16 #[get(type(copy))]
17 pub(crate) width: f64,
18 /// The logical viewport height in CSS pixels.
19 #[get(type(copy))]
20 pub(crate) height: f64,
21 /// The rendering quality preset for canvas smoothing and SSAA downscaling.
22 #[get(type(copy))]
23 #[new(skip)]
24 pub(crate) quality: RenderQuality,
25 /// Whether MSAA anti-aliasing is enabled for the WebGPU backend.
26 ///
27 /// Ignored when `backend` is `Canvas2D`.
28 #[get(type(copy))]
29 #[new(skip)]
30 pub(crate) antialias: bool,
31 /// The power preference hint for WebGPU adapter selection.
32 ///
33 /// Ignored when `backend` is `Canvas2D`.
34 #[get(type(copy))]
35 #[new(skip)]
36 pub(crate) power_preference: GpuPowerPreference,
37 /// The SSAA supersampling scale factor for the Canvas 2D backend.
38 ///
39 /// A value of 2.0 renders at 4x resolution and downscales for smoother
40 /// edges. Ignored when `backend` is `WebGpu`.
41 #[get(type(copy))]
42 #[new(skip)]
43 pub(crate) ssaa_scale_factor: f64,
44}
45
46/// The top-level engine configuration containing rendering and scheduler settings.
47///
48/// Passed to `Engine::new` to configure the engine instance.
49#[derive(Clone, Data, Debug, New, PartialEq)]
50pub struct EngineConfig {
51 /// The rendering configuration.
52 #[get(type(clone))]
53 pub(crate) render: RenderConfig,
54 /// The scheduler configuration controlling the fixed-timestep game loop.
55 #[get(type(copy))]
56 #[new(skip)]
57 pub(crate) scheduler: SchedulerConfig,
58}