diff --git a/include/cglm-cam.h b/include/cglm-cam.h index e69b103..71edb81 100644 --- a/include/cglm-cam.h +++ b/include/cglm-cam.h @@ -68,7 +68,7 @@ glm_ortho_default(mat4 dest) { GLint rect[4]; float aspectRatio; - glGetIntegerv(GL_VIEWPORT, rect); + glm_platfom_get_viewport_rect(rect); aspectRatio = (float)rect[2]/rect[3]; if (rect[2] >= rect[3]) { @@ -114,11 +114,11 @@ glm_perspective(float fovy, CGLM_INLINE void glm_perspective_default(mat4 dest) { - GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); + GLint rect[4]; + glm_platfom_get_viewport_rect(rect); glm_perspective((float)M_PI_4, - (float)viewport[2]/viewport[3], + (float)rect[2]/rect[3], 0.01f, 100.0f, dest); diff --git a/include/cglm-opengl.h b/include/cglm-opengl.h index 7082277..86b5ff1 100644 --- a/include/cglm-opengl.h +++ b/include/cglm-opengl.h @@ -14,7 +14,7 @@ CGLM_INLINE void glm_mat4_uniform(mat4 m, GLint location){ - glUniformMatrix4fv(location, 1, GL_FALSE, m[0]); + glm_platform_uniform_mat4fv(location, m[0]); } #endif /* cglm_mat_opengl_h */ diff --git a/include/cglm-platform.h b/include/cglm-platform.h index a365edf..8fe3282 100644 --- a/include/cglm-platform.h +++ b/include/cglm-platform.h @@ -8,6 +8,8 @@ #ifndef cglm_platform_h #define cglm_platform_h +#include "cglm-common.h" + #ifdef __APPLE__ # include #else @@ -25,6 +27,23 @@ glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); + +extern +void +glGetIntegerv(GLenum pname, GLint *params); #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 */