diff options
| author | HampusM <hampus@hampusmat.com> | 2026-04-18 17:07:50 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-04-18 17:07:50 +0200 |
| commit | 450670dbfb153f00adf431ad77379042a9114ab0 (patch) | |
| tree | 7c31b0b672ddbfcbf4507e8b61f73e9af34909ff /opengl-bindings/src | |
| parent | bb2929df6b013fba82a866cc1dc14e842e94d0af (diff) | |
Diffstat (limited to 'opengl-bindings/src')
| -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 { |
