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/backend/opengl.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'engine/src/rendering/backend') diff --git a/engine/src/rendering/backend/opengl.rs b/engine/src/rendering/backend/opengl.rs index dc636ef..49f857b 100644 --- a/engine/src/rendering/backend/opengl.rs +++ b/engine/src/rendering/backend/opengl.rs @@ -35,10 +35,12 @@ use opengl_bindings::misc::{ define_scissor_box as gl_define_scissor_box, enable, get_viewport as gl_get_viewport, + set_depth_function as gl_set_depth_function, set_enabled, set_viewport as gl_set_viewport, BufferClearMask as GlBufferClearMask, Capability, + DepthFunction as GlDepthFunction, }; use opengl_bindings::shader::{ Error as GlShaderError, @@ -108,6 +110,7 @@ use crate::rendering::{ BufferClearMask, Command, CommandQueue, + DepthFunction, DrawMeshOptions, DrawPropertiesUpdateFlags, GraphicsProperties, @@ -1032,6 +1035,26 @@ fn handle_commands( ); } + if draw_props_update_flags + .contains(DrawPropertiesUpdateFlags::DEPTH_FUNCTION) + { + gl_set_depth_function( + gl_context, + match draw_props.depth_function { + DepthFunction::Never => GlDepthFunction::Never, + DepthFunction::Less => GlDepthFunction::Less, + DepthFunction::Equal => GlDepthFunction::Equal, + DepthFunction::LessOrEqual => GlDepthFunction::LessOrEqual, + DepthFunction::Greater => GlDepthFunction::Greater, + DepthFunction::NotEqual => GlDepthFunction::NotEqual, + DepthFunction::GreaterOrEqual => { + GlDepthFunction::GreaterOrEqual + } + DepthFunction::Always => GlDepthFunction::Always, + }, + ); + } + if draw_props_update_flags .contains(DrawPropertiesUpdateFlags::SCISSOR_TEST_ENABLED) { -- cgit v1.2.3-18-g5258