summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-04-18 13:30:32 +0200
committerHampusM <hampus@hampusmat.com>2026-04-18 13:30:32 +0200
commit75558d144ca8c91ed5e87358d935b2c36eb29d7b (patch)
tree748847bc8a5b6569b2a5901f3a08587a319358d3
parent770b64cb98c7e52d2ed3f75b817aaed5502461ab (diff)
feat(opengl-bindings): add scissor testing
-rw-r--r--opengl-bindings/Cargo.toml3
-rw-r--r--opengl-bindings/src/misc.rs28
2 files changed, 30 insertions, 1 deletions
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<u16>,
+ size: Dimens<u16>,
+)
+{
+ let lower_left_corner_pos = Vec2::<crate::sys::types::GLint> {
+ x: lower_left_corner_pos.x.into(),
+ y: lower_left_corner_pos.y.into(),
+ };
+
+ let size = Dimens::<crate::sys::types::GLsizei> {
+ 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,