From 1eadb384628c374cc88d2baad010dcd2b6abd297 Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Thu, 8 Dec 2016 22:06:52 +0200 Subject: [PATCH] resize helper for perspective * when window resized we only change aspect ratio, so projection still keeps same --- include/cglm-cam.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/cglm-cam.h b/include/cglm-cam.h index ef02a71..6d55637 100644 --- a/include/cglm-cam.h +++ b/include/cglm-cam.h @@ -153,6 +153,18 @@ glm_perspective_default(mat4 dest) { dest); } +CGLM_INLINE +void +glm_perspective_resize(mat4 proj) { + int32_t rect[4]; + + if (proj[0][0] == 0) + return; + + glm_platfom_get_viewport_rect(rect); + proj[0][0] = (float)proj[1][1] * rect[3] / rect[2]; +} + CGLM_INLINE void glm_lookat(vec3 eye,