diff options
Diffstat (limited to 'opengl-bindings/src/misc.rs')
| -rw-r--r-- | opengl-bindings/src/misc.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/opengl-bindings/src/misc.rs b/opengl-bindings/src/misc.rs index 6206b79..3a3335d 100644 --- a/opengl-bindings/src/misc.rs +++ b/opengl-bindings/src/misc.rs @@ -54,6 +54,33 @@ pub fn set_viewport( Ok(()) } +pub fn get_viewport( + current_context: &CurrentContextWithFns<'_>, +) -> (Vec2<u32>, Dimens<u32>) +{ + let mut values = [0i32; 4]; + + unsafe { + current_context + .fns() + .GetIntegerv(crate::sys::VIEWPORT, values.as_mut_ptr()); + } + + let [x, y, width, height] = values; + + let pos = Vec2::<u32> { + x: x.try_into().expect("Negative viewport x coordinate"), + y: y.try_into().expect("Negative viewport y coordinate"), + }; + + let size = Dimens::<u32> { + width: width.try_into().expect("Negative viewport width"), + height: height.try_into().expect("Negative viewport height"), + }; + + (pos, size) +} + pub fn clear_buffers(current_context: &CurrentContextWithFns<'_>, mask: BufferClearMask) { unsafe { |
