diff options
| author | HampusM <hampus@hampusmat.com> | 2026-08-06 16:01:19 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-08-06 16:01:19 +0200 |
| commit | 26a5b10d84dcbb9f22acec30aa549e9992235e9e (patch) | |
| tree | f4db6f0d58b4cee94a4453130da9e054bd4a2112 | |
| parent | af2af06f7bc145e0661def88861f56ca92dd3d89 (diff) | |
feat(opengl-bindings): add fn to set depth function
| -rw-r--r-- | opengl-bindings/Cargo.toml | 3 | ||||
| -rw-r--r-- | opengl-bindings/src/misc.rs | 50 |
2 files changed, 46 insertions, 7 deletions
diff --git a/opengl-bindings/Cargo.toml b/opengl-bindings/Cargo.toml index c08b94a..f2252a7 100644 --- a/opengl-bindings/Cargo.toml +++ b/opengl-bindings/Cargo.toml @@ -67,5 +67,6 @@ gl_commands = [ "BindBufferBase", "BlendFunc", "BlendEquation", - "Scissor" + "Scissor", + "DepthFunc", ] diff --git a/opengl-bindings/src/misc.rs b/opengl-bindings/src/misc.rs index 047221b..a0d36e3 100644 --- a/opengl-bindings/src/misc.rs +++ b/opengl-bindings/src/misc.rs @@ -81,10 +81,7 @@ pub fn get_viewport( (pos, size) } -pub fn clear_buffers( - current_context: &MaybeCurrentContextWithFns, - mask: BufferClearMask, -) +pub fn clear_buffers(current_context: &MaybeCurrentContextWithFns, mask: BufferClearMask) { unsafe { current_context.fns().Clear(mask.bits()); @@ -132,8 +129,7 @@ pub fn set_enabled( } #[must_use] -pub fn get_context_flags(current_context: &MaybeCurrentContextWithFns) - -> ContextFlags +pub fn get_context_flags(current_context: &MaybeCurrentContextWithFns) -> ContextFlags { let mut context_flags = crate::sys::types::GLint::default(); @@ -173,6 +169,16 @@ pub fn define_scissor_box( } } +pub fn set_depth_function( + current_context: &MaybeCurrentContextWithFns, + depth_function: DepthFunction, +) +{ + unsafe { + current_context.fns().DepthFunc(depth_function as u32); + } +} + bitflags! { #[derive(Debug, Clone, Copy)] pub struct BufferClearMask: u32 { @@ -223,6 +229,38 @@ pub struct ContextFlags: u32 { } } +#[derive(Debug, Default, Clone, Copy)] +#[repr(u32)] +pub enum DepthFunction +{ + /// Never passes. + Never = crate::sys::NEVER, + + /// Passes if the incoming depth value is less than the stored depth value. + #[default] + Less = crate::sys::LESS, + + /// Passes if the incoming depth value is equal to the stored depth value. + Equal = crate::sys::EQUAL, + + /// Passes if the incoming depth value is less than or equal to the stored depth + /// value. + LessOrEqual = crate::sys::LEQUAL, + + /// Passes if the incoming depth value is greater than the stored depth value. + Greater = crate::sys::GREATER, + + /// Passes if the incoming depth value is not equal to the stored depth value. + NotEqual = crate::sys::NOTEQUAL, + + /// Passes if the incoming depth value is greater than or equal to the stored depth + /// value. + GreaterOrEqual = crate::sys::GEQUAL, + + /// Always passes. + Always = crate::sys::ALWAYS, +} + #[derive(Debug, thiserror::Error)] pub enum SetViewportError { |
