mirror of
https://github.com/recp/cglm.git
synced 2026-02-17 03:39:05 +00:00
drop platform (OpenGL) specific codes
This commit is contained in:
@@ -9,7 +9,6 @@
|
|||||||
#define cglm_vcam_h
|
#define cglm_vcam_h
|
||||||
|
|
||||||
#include "cglm-common.h"
|
#include "cglm-common.h"
|
||||||
#include "cglm-platform.h"
|
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
@@ -65,14 +64,9 @@ glm_ortho(float left,
|
|||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_ortho_default(mat4 dest) {
|
glm_ortho_default(float aspectRatio,
|
||||||
int32_t rect[4];
|
mat4 dest) {
|
||||||
float aspectRatio;
|
if (aspectRatio >= 1.0f) {
|
||||||
|
|
||||||
glm_platfom_get_viewport_rect(rect);
|
|
||||||
aspectRatio = (float)rect[2]/rect[3];
|
|
||||||
|
|
||||||
if (rect[2] >= rect[3]) {
|
|
||||||
glm_ortho(-1.0f * aspectRatio,
|
glm_ortho(-1.0f * aspectRatio,
|
||||||
1.0f * aspectRatio,
|
1.0f * aspectRatio,
|
||||||
-1.0f,
|
-1.0f,
|
||||||
@@ -80,27 +74,24 @@ glm_ortho_default(mat4 dest) {
|
|||||||
-100.0f,
|
-100.0f,
|
||||||
100.0f,
|
100.0f,
|
||||||
dest);
|
dest);
|
||||||
} else {
|
return;
|
||||||
glm_ortho(-1.0f,
|
|
||||||
1.0f,
|
|
||||||
-1.0f / aspectRatio,
|
|
||||||
1.0f / aspectRatio,
|
|
||||||
-100.0f,
|
|
||||||
100.0f,
|
|
||||||
dest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm_ortho(-1.0f,
|
||||||
|
1.0f,
|
||||||
|
-1.0f / aspectRatio,
|
||||||
|
1.0f / aspectRatio,
|
||||||
|
-100.0f,
|
||||||
|
100.0f,
|
||||||
|
dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_ortho_default_s(float size, mat4 dest) {
|
glm_ortho_default_s(float aspectRatio,
|
||||||
int32_t rect[4];
|
float size,
|
||||||
float aspectRatio;
|
mat4 dest) {
|
||||||
|
if (aspectRatio >= 1.0f) {
|
||||||
glm_platfom_get_viewport_rect(rect);
|
|
||||||
aspectRatio = (float)rect[2]/rect[3];
|
|
||||||
|
|
||||||
if (rect[2] >= rect[3]) {
|
|
||||||
glm_ortho(-size * aspectRatio,
|
glm_ortho(-size * aspectRatio,
|
||||||
size * aspectRatio,
|
size * aspectRatio,
|
||||||
-size,
|
-size,
|
||||||
@@ -108,15 +99,16 @@ glm_ortho_default_s(float size, mat4 dest) {
|
|||||||
-size - 100.0f,
|
-size - 100.0f,
|
||||||
size + 100.0f,
|
size + 100.0f,
|
||||||
dest);
|
dest);
|
||||||
} else {
|
return;
|
||||||
glm_ortho(-size,
|
|
||||||
size,
|
|
||||||
-size / aspectRatio,
|
|
||||||
size / aspectRatio,
|
|
||||||
-size - 100.0f,
|
|
||||||
size + 100.0f,
|
|
||||||
dest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm_ortho(-size,
|
||||||
|
size,
|
||||||
|
-size / aspectRatio,
|
||||||
|
size / aspectRatio,
|
||||||
|
-size - 100.0f,
|
||||||
|
size + 100.0f,
|
||||||
|
dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
@@ -142,12 +134,9 @@ glm_perspective(float fovy,
|
|||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_perspective_default(mat4 dest) {
|
glm_perspective_default(float aspectRatio, mat4 dest) {
|
||||||
int32_t rect[4];
|
|
||||||
glm_platfom_get_viewport_rect(rect);
|
|
||||||
|
|
||||||
glm_perspective((float)CGLM_PI_4,
|
glm_perspective((float)CGLM_PI_4,
|
||||||
(float)rect[2]/rect[3],
|
aspectRatio,
|
||||||
0.01f,
|
0.01f,
|
||||||
100.0f,
|
100.0f,
|
||||||
dest);
|
dest);
|
||||||
@@ -155,14 +144,12 @@ glm_perspective_default(mat4 dest) {
|
|||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
void
|
void
|
||||||
glm_perspective_resize(mat4 proj) {
|
glm_perspective_resize(float aspectRatio,
|
||||||
int32_t rect[4];
|
mat4 proj) {
|
||||||
|
|
||||||
if (proj[0][0] == 0)
|
if (proj[0][0] == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm_platfom_get_viewport_rect(rect);
|
proj[0][0] = proj[1][1] / aspectRatio;
|
||||||
proj[0][0] = (float)proj[1][1] * rect[3] / rect[2];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLM_INLINE
|
CGLM_INLINE
|
||||||
|
|||||||
@@ -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 */
|
|
||||||
@@ -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 <OpenGL/gl3.h>
|
|
||||||
#else
|
|
||||||
# ifdef _WIN32
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
|
||||||
# include <windows.h>
|
|
||||||
# endif
|
|
||||||
# include <GL/gl.h>
|
|
||||||
#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 */
|
|
||||||
@@ -32,8 +32,6 @@ nobase_include_HEADERS = include/cglm.h \
|
|||||||
include/cglm-quat.h \
|
include/cglm-quat.h \
|
||||||
include/cglm-mat.h \
|
include/cglm-mat.h \
|
||||||
include/cglm-affine-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-mat-simd-avx.h \
|
||||||
include/arch/simd/cglm-affine-mat-avx.h \
|
include/arch/simd/cglm-affine-mat-avx.h \
|
||||||
include/arch/simd/cglm-quat-simd.h \
|
include/arch/simd/cglm-quat-simd.h \
|
||||||
|
|||||||
Reference in New Issue
Block a user