From 7083a19bf1029bff21a9550d40cc3260e99aac53 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 18 Oct 2025 17:04:28 +0200 Subject: refactor(engine): use winit instead of glfw --- engine/src/renderer.rs | 70 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 3 deletions(-) (limited to 'engine/src/renderer.rs') diff --git a/engine/src/renderer.rs b/engine/src/renderer.rs index fcc96cc..6d25f6b 100644 --- a/engine/src/renderer.rs +++ b/engine/src/renderer.rs @@ -1,6 +1,8 @@ -use ecs::declare_entity; use ecs::pair::{ChildOf, Pair}; -use ecs::phase::{Phase, UPDATE as UPDATE_PHASE}; +use ecs::phase::{Phase, POST_UPDATE as POST_UPDATE_PHASE}; +use ecs::{declare_entity, Component}; + +use crate::builder; pub mod opengl; @@ -10,7 +12,69 @@ declare_entity!( Phase, Pair::builder() .relation::() - .target_id(*UPDATE_PHASE) + .target_id(*POST_UPDATE_PHASE) .build() ) ); + +builder! { +/// Window graphics properties. +#[builder(name=GraphicsPropertiesBuilder, derives=(Debug, Clone))] +#[derive(Debug, Clone, Component)] +#[non_exhaustive] +pub struct GraphicsProperties +{ + /// Number of samples for multisampling. `None` means no multisampling. + #[builder(skip_generate_fn)] + pub multisampling_sample_cnt: Option, + + /// Whether graphics API debugging is enabled. + pub debug: bool, + + /// Whether depth testing is enabled + pub depth_test: bool, +} +} + +impl GraphicsProperties +{ + pub fn builder() -> GraphicsPropertiesBuilder + { + GraphicsPropertiesBuilder::default() + } +} + +impl Default for GraphicsProperties +{ + fn default() -> Self + { + Self::builder().build() + } +} + +impl GraphicsPropertiesBuilder +{ + pub fn multisampling_sample_cnt(mut self, multisampling_sample_cnt: u8) -> Self + { + self.multisampling_sample_cnt = Some(multisampling_sample_cnt); + self + } + + pub fn no_multisampling(mut self) -> Self + { + self.multisampling_sample_cnt = None; + self + } +} + +impl Default for GraphicsPropertiesBuilder +{ + fn default() -> Self + { + Self { + multisampling_sample_cnt: Some(8), + debug: false, + depth_test: true, + } + } +} -- cgit v1.2.3-18-g5258