From 146635292369cc8a9660139d97cd9662025bd591 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 7 Oct 2023 20:05:52 +0200 Subject: fix(engine): update viewport when framebuffer changes size --- engine/src/renderer/mod.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'engine/src/renderer/mod.rs') diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs index c34441c..9cd379d 100644 --- a/engine/src/renderer/mod.rs +++ b/engine/src/renderer/mod.rs @@ -1,6 +1,8 @@ use std::ffi::{c_void, CString}; use std::process::abort; +use glfw::WindowSize; + use crate::vector::Vec2; pub fn initialize(window: &glfw::Window) -> Result<(), Error> @@ -35,15 +37,7 @@ pub fn render() } } -/// Renderer error. -#[derive(Debug, thiserror::Error)] -pub enum Error -{ - #[error("Failed to get window size")] - GetWindowSizeFailed(#[source] glfw::Error), -} - -fn set_viewport(position: &Vec2, size: &crate::WindowSize) +pub fn set_viewport(position: &Vec2, size: &WindowSize) { unsafe { #[allow(clippy::cast_possible_wrap)] @@ -55,3 +49,11 @@ fn set_viewport(position: &Vec2, size: &crate::WindowSize) ); } } + +/// Renderer error. +#[derive(Debug, thiserror::Error)] +pub enum Error +{ + #[error("Failed to get window size")] + GetWindowSizeFailed(#[source] glfw::Error), +} -- cgit v1.2.3-18-g5258