From 6f683a66582dd543b957216b466c07dc64d5b9a7 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 6 Aug 2026 16:15:00 +0200 Subject: feat(engine): add depth function to rendering::DrawProperties --- engine/src/rendering.rs | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'engine/src/rendering.rs') diff --git a/engine/src/rendering.rs b/engine/src/rendering.rs index dc3cb76..3af1ab8 100644 --- a/engine/src/rendering.rs +++ b/engine/src/rendering.rs @@ -321,6 +321,37 @@ impl Default for ScissorBox } } +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] +pub enum DepthFunction +{ + /// Never passes. + Never, + + /// Passes if the incoming depth value is less than the stored depth value. + #[default] + Less, + + /// Passes if the incoming depth value is equal to the stored depth value. + Equal, + + /// Passes if the incoming depth value is less than or equal to the stored depth + /// value. + LessOrEqual, + + /// Passes if the incoming depth value is greater than the stored depth value. + Greater, + + /// Passes if the incoming depth value is not equal to the stored depth value. + NotEqual, + + /// Passes if the incoming depth value is greater than or equal to the stored depth + /// value. + GreaterOrEqual, + + /// Always passes. + Always, +} + #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub struct DrawProperties @@ -329,6 +360,7 @@ pub struct DrawProperties pub blending_enabled: bool, pub blending_config: BlendingConfig, pub depth_test_enabled: bool, + pub depth_function: DepthFunction, pub scissor_test_enabled: bool, pub scissor_box: ScissorBox, pub face_culling_enabled: bool, @@ -343,6 +375,7 @@ impl Default for DrawProperties blending_enabled: false, blending_config: BlendingConfig::default(), depth_test_enabled: true, + depth_function: DepthFunction::default(), scissor_test_enabled: false, scissor_box: ScissorBox::default(), face_culling_enabled: false, @@ -358,9 +391,10 @@ bitflags! { const BLENDING_CONFIG = 1 << 1; const BLENDING_ENABLED = 1 << 2; const DEPTH_TEST_ENABLED = 1 << 3; - const SCISSOR_TEST_ENABLED = 1 << 4; - const SCISSOR_BOX = 1 << 5; - const FACE_CULLING_ENABLED = 1 << 6; + const DEPTH_FUNCTION = 1 << 4; + const SCISSOR_TEST_ENABLED = 1 << 5; + const SCISSOR_BOX = 1 << 6; + const FACE_CULLING_ENABLED = 1 << 7; } } -- cgit v1.2.3-18-g5258