#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HardwareAcceleration {
Required,
Preferred,
Off,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[allow(dead_code)]
pub struct SurfaceSettings {
pub vsync: bool,
pub depth_buffer: u8,
pub stencil_buffer: u8,
pub multisamples: u8,
pub hardware_acceleration: HardwareAcceleration,
}
impl Default for SurfaceSettings {
fn default() -> Self {
Self {
vsync: true,
depth_buffer: 24,
stencil_buffer: 0,
multisamples: 4,
hardware_acceleration: HardwareAcceleration::Preferred,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WindowSettings {
pub title: String,
pub min_size: (u32, u32),
pub max_size: Option<(u32, u32)>,
pub initial_size: Option<(u32, u32)>,
pub borderless: bool,
#[cfg(target_arch = "wasm32")]
pub canvas: Option<web_sys::HtmlCanvasElement>,
pub surface_settings: SurfaceSettings,
}
impl Default for WindowSettings {
fn default() -> Self {
Self {
title: "".to_string(),
min_size: (2, 2),
max_size: None,
initial_size: None,
borderless: false,
#[cfg(target_arch = "wasm32")]
canvas: None,
surface_settings: SurfaceSettings::default(),
}
}
}
impl std::ops::Deref for WindowSettings {
type Target = SurfaceSettings;
fn deref(&self) -> &Self::Target {
&self.surface_settings
}
}
impl std::ops::DerefMut for WindowSettings {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.surface_settings
}
}