From 2ebdfaeeafbb11f8b04133ef35f8429eb7caa6e6 Mon Sep 17 00:00:00 2001 From: Recep Aslantas Date: Sun, 9 Oct 2016 18:06:52 +0300 Subject: [PATCH] helper ortho proj --- include/cglm-cam.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/include/cglm-cam.h b/include/cglm-cam.h index 71edb81..ea2dca6 100644 --- a/include/cglm-cam.h +++ b/include/cglm-cam.h @@ -90,6 +90,34 @@ glm_ortho_default(mat4 dest) { } } +CGLM_INLINE +void +glm_ortho_default_s(float size, mat4 dest) { + GLint rect[4]; + float aspectRatio; + + glm_platfom_get_viewport_rect(rect); + aspectRatio = (float)rect[2]/rect[3]; + + if (rect[2] >= rect[3]) { + glm_ortho(-size * aspectRatio, + size * aspectRatio, + -size, + size, + size + 100.0f, + -size - 100.0f, + dest); + } else { + glm_ortho(-size, + size, + -size / aspectRatio, + size / aspectRatio, + size + 100.0f, + -size - 100.0f, + dest); + } +} + CGLM_INLINE void glm_perspective(float fovy,