summaryrefslogtreecommitdiff
path: root/engine/src/renderer.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2025-10-18 17:04:28 +0200
committerHampusM <hampus@hampusmat.com>2025-10-18 17:04:28 +0200
commit7083a19bf1029bff21a9550d40cc3260e99aac53 (patch)
tree524a8bd2e75ca712b0536218089804cf9838553b /engine/src/renderer.rs
parent7f3072ed7e016dff359439d7580403e36ad6b325 (diff)
refactor(engine): use winit instead of glfw
Diffstat (limited to 'engine/src/renderer.rs')
-rw-r--r--engine/src/renderer.rs70
1 files changed, 67 insertions, 3 deletions
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::<ChildOf>()
- .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<u8>,
+
+ /// 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,
+ }
+ }
+}