diff --git a/include/cglm-cam.h b/include/cglm-cam.h index 171d826..154c705 100644 --- a/include/cglm-cam.h +++ b/include/cglm-cam.h @@ -9,7 +9,6 @@ #define cglm_vcam_h #include "cglm-common.h" -#include "cglm-platform.h" CGLM_INLINE void @@ -65,14 +64,9 @@ glm_ortho(float left, CGLM_INLINE void -glm_ortho_default(mat4 dest) { - int32_t rect[4]; - float aspectRatio; - - glm_platfom_get_viewport_rect(rect); - aspectRatio = (float)rect[2]/rect[3]; - - if (rect[2] >= rect[3]) { +glm_ortho_default(float aspectRatio, + mat4 dest) { + if (aspectRatio >= 1.0f) { glm_ortho(-1.0f * aspectRatio, 1.0f * aspectRatio, -1.0f, @@ -80,27 +74,24 @@ glm_ortho_default(mat4 dest) { -100.0f, 100.0f, dest); - } else { - glm_ortho(-1.0f, - 1.0f, - -1.0f / aspectRatio, - 1.0f / aspectRatio, - -100.0f, - 100.0f, - dest); + return; } + + glm_ortho(-1.0f, + 1.0f, + -1.0f / aspectRatio, + 1.0f / aspectRatio, + -100.0f, + 100.0f, + dest); } CGLM_INLINE void -glm_ortho_default_s(float size, mat4 dest) { - int32_t rect[4]; - float aspectRatio; - - glm_platfom_get_viewport_rect(rect); - aspectRatio = (float)rect[2]/rect[3]; - - if (rect[2] >= rect[3]) { +glm_ortho_default_s(float aspectRatio, + float size, + mat4 dest) { + if (aspectRatio >= 1.0f) { glm_ortho(-size * aspectRatio, size * aspectRatio, -size, @@ -108,15 +99,16 @@ glm_ortho_default_s(float size, mat4 dest) { -size - 100.0f, size + 100.0f, dest); - } else { - glm_ortho(-size, - size, - -size / aspectRatio, - size / aspectRatio, - -size - 100.0f, - size + 100.0f, - dest); + return; } + + glm_ortho(-size, + size, + -size / aspectRatio, + size / aspectRatio, + -size - 100.0f, + size + 100.0f, + dest); } CGLM_INLINE @@ -142,12 +134,9 @@ glm_perspective(float fovy, CGLM_INLINE void -glm_perspective_default(mat4 dest) { - int32_t rect[4]; - glm_platfom_get_viewport_rect(rect); - +glm_perspective_default(float aspectRatio, mat4 dest) { glm_perspective((float)CGLM_PI_4, - (float)rect[2]/rect[3], + aspectRatio, 0.01f, 100.0f, dest); @@ -155,14 +144,12 @@ glm_perspective_default(mat4 dest) { CGLM_INLINE void -glm_perspective_resize(mat4 proj) { - int32_t rect[4]; - +glm_perspective_resize(float aspectRatio, + mat4 proj) { if (proj[0][0] == 0) return; - glm_platfom_get_viewport_rect(rect); - proj[0][0] = (float)proj[1][1] * rect[3] / rect[2]; + proj[0][0] = proj[1][1] / aspectRatio; } CGLM_INLINE diff --git a/include/cglm-opengl.h b/include/cglm-opengl.h deleted file mode 100644 index bdc4269..0000000 --- a/include/cglm-opengl.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c), Recep Aslantas. - * - * MIT License (MIT), http://opensource.org/licenses/MIT - * Full license can be found in the LICENSE file - */ - -#ifndef cglm_mat_opengl_h -#define cglm_mat_opengl_h - -#include "cglm-common.h" -#include "cglm-platform.h" - -CGLM_INLINE -void -glm_uniform(int32_t location, mat4 m) { - glm_platform_uniform_mat4fv(location, m[0]); -} - -#endif /* cglm_mat_opengl_h */ diff --git a/include/cglm-platform.h b/include/cglm-platform.h deleted file mode 100644 index 87957a6..0000000 --- a/include/cglm-platform.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c), Recep Aslantas. - * - * MIT License (MIT), http://opensource.org/licenses/MIT - * Full license can be found in the LICENSE file - */ - -#ifndef cglm_platform_h -#define cglm_platform_h - -#include "cglm-common.h" - -#ifdef __APPLE__ -# include -#else -# ifdef _WIN32 -# define WIN32_LEAN_AND_MEAN -# include -# endif -# include -#endif - -#ifdef _WIN32 -extern -void -glUniformMatrix4fv(GLint location, - GLsizei count, - GLboolean transpose, - const GLfloat *value); -#endif - -CGLM_INLINE -void -glm_platform_uniform_mat4fv(int32_t location, - const float *value) { - glUniformMatrix4fv(location, 1, GL_FALSE, value); -} - -CGLM_INLINE -void -glm_platfom_get_viewport_rect(int32_t *rect) { - glGetIntegerv(GL_VIEWPORT, rect); -} - -#endif /* cglm_platform_h */ diff --git a/makefile.am b/makefile.am index 7c2b4b0..eac1d25 100644 --- a/makefile.am +++ b/makefile.am @@ -32,8 +32,6 @@ nobase_include_HEADERS = include/cglm.h \ include/cglm-quat.h \ include/cglm-mat.h \ include/cglm-affine-mat.h \ - include/cglm-platform.h \ - include/cglm-opengl.h \ include/arch/simd/cglm-mat-simd-avx.h \ include/arch/simd/cglm-affine-mat-avx.h \ include/arch/simd/cglm-quat-simd.h \