From 75558d144ca8c91ed5e87358d935b2c36eb29d7b Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 18 Apr 2026 13:30:32 +0200 Subject: feat(opengl-bindings): add scissor testing --- opengl-bindings/Cargo.toml | 3 ++- opengl-bindings/src/misc.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/opengl-bindings/Cargo.toml b/opengl-bindings/Cargo.toml index b6eadba..ae51a34 100644 --- a/opengl-bindings/Cargo.toml +++ b/opengl-bindings/Cargo.toml @@ -66,5 +66,6 @@ gl_commands = [ "DeleteBuffers", "BindBufferBase", "BlendFunc", - "BlendEquation" + "BlendEquation", + "Scissor" ] diff --git a/opengl-bindings/src/misc.rs b/opengl-bindings/src/misc.rs index 2acc4bb..6206b79 100644 --- a/opengl-bindings/src/misc.rs +++ b/opengl-bindings/src/misc.rs @@ -115,6 +115,33 @@ pub fn get_context_flags(current_context: &CurrentContextWithFns<'_>) -> Context ContextFlags::from_bits_truncate(context_flags.cast_unsigned()) } +/// Defines a rectangle, called the scissor box, in window coordinates. +pub fn define_scissor_box( + current_context: &CurrentContextWithFns<'_>, + lower_left_corner_pos: Vec2, + size: Dimens, +) +{ + let lower_left_corner_pos = Vec2:: { + x: lower_left_corner_pos.x.into(), + y: lower_left_corner_pos.y.into(), + }; + + let size = Dimens:: { + width: size.width.into(), + height: size.height.into(), + }; + + unsafe { + current_context.fns().Scissor( + lower_left_corner_pos.x, + lower_left_corner_pos.y, + size.width, + size.height, + ); + } +} + bitflags! { #[derive(Debug, Clone, Copy)] pub struct BufferClearMask: u32 { @@ -130,6 +157,7 @@ bitflags! { pub enum Capability { DepthTest = crate::sys::DEPTH_TEST, + ScissorTest = crate::sys::SCISSOR_TEST, MultiSample = crate::sys::MULTISAMPLE, DebugOutput = crate::sys::DEBUG_OUTPUT, DebugOutputSynchronous = crate::sys::DEBUG_OUTPUT_SYNCHRONOUS, -- cgit v1.2.3-18-g5258