mirror of
https://github.com/recp/cglm.git
synced 2025-10-03 16:51:35 +00:00
clipspace: add initial implementations LH, RH and NO, ZO
Add the initial implementations of the left-handed and right-handed coordinate systems as well as clipspace depth values of [-1, 0] and [0, 1].
This commit is contained in:
@@ -57,10 +57,7 @@ add_library(${PROJECT_NAME}
|
||||
src/io.c
|
||||
src/quat.c
|
||||
src/cam.c
|
||||
src/cam_lh_zo.c
|
||||
src/cam_rh_zo.c
|
||||
src/cam_lh_no.c
|
||||
src/cam_rh_no.c
|
||||
src/vec2.c
|
||||
src/vec2.c
|
||||
src/vec3.c
|
||||
src/vec4.c
|
||||
@@ -77,6 +74,18 @@ add_library(${PROJECT_NAME}
|
||||
src/bezier.c
|
||||
src/ray.c
|
||||
src/affine2d.c
|
||||
src/clipspace/persp_lh_zo.c
|
||||
src/clipspace/persp_rh_zo.c
|
||||
src/clipspace/persp_lh_no.c
|
||||
src/clipspace/persp_rh_no.c
|
||||
src/clipspace/ortho_lh_zo.c
|
||||
src/clipspace/ortho_rh_zo.c
|
||||
src/clipspace/ortho_lh_no.c
|
||||
src/clipspace/ortho_rh_no.c
|
||||
src/clipspace/view_lh_zo.c
|
||||
src/clipspace/view_rh_zo.c
|
||||
src/clipspace/view_lh_no.c
|
||||
src/clipspace/view_rh_no.c
|
||||
)
|
||||
|
||||
if(CGLM_SHARED)
|
||||
|
21
Makefile.am
21
Makefile.am
@@ -41,10 +41,6 @@ cglm_HEADERS = include/cglm/version.h \
|
||||
include/cglm/call.h \
|
||||
include/cglm/struct.h \
|
||||
include/cglm/cam.h \
|
||||
include/cglm/cam_lh_zo.h \
|
||||
include/cglm/cam_rh_zo.h \
|
||||
include/cglm/cam_lh_no.h \
|
||||
include/cglm/cam_rh_no.h \
|
||||
include/cglm/io.h \
|
||||
include/cglm/mat4.h \
|
||||
include/cglm/mat3.h \
|
||||
@@ -73,6 +69,23 @@ cglm_HEADERS = include/cglm/version.h \
|
||||
include/cglm/ray.h \
|
||||
include/cglm/affine2d.h
|
||||
|
||||
cglm_clipspacedir=$(includedir)/cglm/clipspace
|
||||
cglm_clipspace_HEADERS = include/cglm/clipspace/persp.h \
|
||||
include/cglm/clipspace/persp_lh_zo.h \
|
||||
include/cglm/clipspace/persp_rh_zo.h \
|
||||
include/cglm/clipspace/persp_lh_no.h \
|
||||
include/cglm/clipspace/persp_rh_no.h \
|
||||
include/cglm/clipspace/ortho_lh_zo.h \
|
||||
include/cglm/clipspace/ortho_rh_zo.h \
|
||||
include/cglm/clipspace/ortho_lh_no.h \
|
||||
include/cglm/clipspace/ortho_rh_no.h \
|
||||
include/cglm/clipspace/view_lh.h \
|
||||
include/cglm/clipspace/view_rh.h \
|
||||
include/cglm/clipspace/view_lh_zo.h \
|
||||
include/cglm/clipspace/view_rh_zo.h \
|
||||
include/cglm/clipspace/view_lh_no.h \
|
||||
include/cglm/clipspace/view_rh_no.h
|
||||
|
||||
cglm_calldir=$(includedir)/cglm/call
|
||||
cglm_call_HEADERS = include/cglm/call/mat4.h \
|
||||
include/cglm/call/mat3.h \
|
||||
|
46
include/cglm/call/clipspace/ortho_lh_no.h
Normal file
46
include/cglm/call/clipspace/ortho_lh_no.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_ortho_lh_no_h
|
||||
#define cglmc_ortho_lh_no_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_lh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_lh_no(vec3 box[2], mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_p_lh_no(vec3 box[2], float padding, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_pz_lh_no(vec3 box[2], float padding, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_lh_no(float aspect, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_s_lh_no(float aspect, float size, mat4 dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_ortho_lh_no_h */
|
46
include/cglm/call/clipspace/ortho_lh_zo.h
Normal file
46
include/cglm/call/clipspace/ortho_lh_zo.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_ortho_lh_zo_h
|
||||
#define cglmc_ortho_lh_zo_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_lh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_lh_zo(vec3 box[2], mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_p_lh_zo(vec3 box[2], float padding, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_pz_lh_zo(vec3 box[2], float padding, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_lh_zo(float aspect, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_s_lh_zo(float aspect, float size, mat4 dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_ortho_lh_zo_h */
|
46
include/cglm/call/clipspace/ortho_rh_no.h
Normal file
46
include/cglm/call/clipspace/ortho_rh_no.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_ortho_rh_no_h
|
||||
#define cglmc_ortho_rh_no_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_rh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_rh_no(vec3 box[2], mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_p_rh_no(vec3 box[2], float padding, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_pz_rh_no(vec3 box[2], float padding, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_rh_no(float aspect, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_s_rh_no(float aspect, float size, mat4 dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_ortho_rh_no_h */
|
46
include/cglm/call/clipspace/ortho_rh_zo.h
Normal file
46
include/cglm/call/clipspace/ortho_rh_zo.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_ortho_rh_zo_h
|
||||
#define cglmc_ortho_rh_zo_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_rh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_rh_zo(vec3 box[2], mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_p_rh_zo(vec3 box[2], float padding, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_pz_rh_zo(vec3 box[2], float padding, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_rh_zo(float aspect, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_s_rh_zo(float aspect, float size, mat4 dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_ortho_rh_zo_h */
|
87
include/cglm/call/clipspace/persp_lh_no.h
Normal file
87
include/cglm/call/clipspace/persp_lh_no.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_persp_lh_no_h
|
||||
#define cglmc_persp_lh_no_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_frustum_lh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_lh_no(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_move_far_lh_no(mat4 proj, float deltaFar);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_lh_no(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decompv_lh_no(mat4 proj, float dest[6]);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_x_lh_no(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_y_lh_no(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_z_lh_no(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_far_lh_no(mat4 proj, float * __restrict farZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_near_lh_no(mat4 proj, float * __restrict nearZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_sizes_lh_no(mat4 proj, float fovy, vec4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_fovy_lh_no(mat4 proj);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_aspect_lh_no(mat4 proj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_persp_lh_no_h */
|
87
include/cglm/call/clipspace/persp_lh_zo.h
Normal file
87
include/cglm/call/clipspace/persp_lh_zo.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_persp_lh_zo_h
|
||||
#define cglmc_persp_lh_zo_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_frustum_lh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_lh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_move_far_lh_zo(mat4 proj, float deltaFar);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_lh_zo(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decompv_lh_zo(mat4 proj, float dest[6]);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_x_lh_zo(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_y_lh_zo(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_z_lh_zo(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_far_lh_zo(mat4 proj, float * __restrict farZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_near_lh_zo(mat4 proj, float * __restrict nearZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_sizes_lh_zo(mat4 proj, float fovy, vec4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_fovy_lh_zo(mat4 proj);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_aspect_lh_zo(mat4 proj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_persp_lh_zo_h */
|
87
include/cglm/call/clipspace/persp_rh_no.h
Normal file
87
include/cglm/call/clipspace/persp_rh_no.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_persp_rh_no_h
|
||||
#define cglmc_persp_rh_no_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_frustum_rh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_rh_no(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_move_far_rh_no(mat4 proj, float deltaFar);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_rh_no(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decompv_rh_no(mat4 proj, float dest[6]);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_x_rh_no(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_y_rh_no(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_z_rh_no(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_far_rh_no(mat4 proj, float * __restrict farZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_near_rh_no(mat4 proj, float * __restrict nearZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_sizes_rh_no(mat4 proj, float fovy, vec4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_fovy_rh_no(mat4 proj);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_aspect_rh_no(mat4 proj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_persp_rh_no_h */
|
87
include/cglm/call/clipspace/persp_rh_zo.h
Normal file
87
include/cglm/call/clipspace/persp_rh_zo.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_persp_rh_zo_h
|
||||
#define cglmc_persp_rh_zo_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_frustum_rh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_rh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_move_far_rh_zo(mat4 proj, float deltaFar);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_rh_zo(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decompv_rh_zo(mat4 proj, float dest[6]);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_x_rh_zo(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_y_rh_zo(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_z_rh_zo(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_far_rh_zo(mat4 proj, float * __restrict farZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_near_rh_zo(mat4 proj, float * __restrict nearZ);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_sizes_rh_zo(mat4 proj, float fovy, vec4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_fovy_rh_zo(mat4 proj);
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_aspect_rh_zo(mat4 proj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_persp_rh_zo_h */
|
31
include/cglm/call/clipspace/view_lh_no.h
Normal file
31
include/cglm/call/clipspace/view_lh_no.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_view_lh_no_h
|
||||
#define cglmc_view_lh_no_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_lookat_lh_no(vec3 eye, vec3 center, vec3 up, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_lh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_anyup_lh_no(vec3 eye, vec3 dir, mat4 dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_view_lh_no_h */
|
31
include/cglm/call/clipspace/view_lh_zo.h
Normal file
31
include/cglm/call/clipspace/view_lh_zo.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_view_lh_zo_h
|
||||
#define cglmc_view_lh_zo_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_lookat_lh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_lh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_anyup_lh_zo(vec3 eye, vec3 dir, mat4 dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_view_lh_zo_h */
|
31
include/cglm/call/clipspace/view_rh_no.h
Normal file
31
include/cglm/call/clipspace/view_rh_no.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_view_rh_no_h
|
||||
#define cglmc_view_rh_no_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_lookat_rh_no(vec3 eye, vec3 center, vec3 up, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_rh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_anyup_rh_no(vec3 eye, vec3 dir, mat4 dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_view_rh_no_h */
|
31
include/cglm/call/clipspace/view_rh_zo.h
Normal file
31
include/cglm/call/clipspace/view_rh_zo.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_view_rh_zo_h
|
||||
#define cglmc_view_rh_zo_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_lookat_rh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_rh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest);
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_anyup_rh_zo(vec3 eye, vec3 dir, mat4 dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_view_rh_zo_h */
|
@@ -45,12 +45,47 @@
|
||||
CGLM_INLINE void glm_persp_sizes(mat4 proj, float fovy, vec4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_vcam_h
|
||||
#define cglm_vcam_h
|
||||
#ifndef cglm_cam_h
|
||||
#define cglm_cam_h
|
||||
|
||||
#include "common.h"
|
||||
#include "plane.h"
|
||||
|
||||
#include "clipspace/persp.h"
|
||||
|
||||
#ifndef CGLM_CLIPSPACE_INCLUDE_ALL
|
||||
# if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
# include "clipspace/ortho_lh_zo.h"
|
||||
# include "clipspace/persp_lh_zo.h"
|
||||
# include "clipspace/view_lh_zo.h"
|
||||
# elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
# include "clipspace/ortho_lh_no.h"
|
||||
# include "clipspace/persp_lh_no.h"
|
||||
# include "clipspace/view_lh_no.h"
|
||||
# elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
# include "clipspace/ortho_rh_zo.h"
|
||||
# include "clipspace/persp_rh_zo.h"
|
||||
# include "clipspace/view_rh_zo.h"
|
||||
# elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
# include "clipspace/ortho_rh_no.h"
|
||||
# include "clipspace/persp_rh_no.h"
|
||||
# include "clipspace/view_rh_no.h"
|
||||
# endif
|
||||
#else
|
||||
# include "clipspace/ortho_lh_zo.h"
|
||||
# include "clipspace/persp_lh_zo.h"
|
||||
# include "clipspace/ortho_lh_no.h"
|
||||
# include "clipspace/persp_lh_no.h"
|
||||
# include "clipspace/ortho_rh_zo.h"
|
||||
# include "clipspace/persp_rh_zo.h"
|
||||
# include "clipspace/ortho_rh_no.h"
|
||||
# include "clipspace/persp_rh_no.h"
|
||||
# include "clipspace/view_lh_zo.h"
|
||||
# include "clipspace/view_lh_no.h"
|
||||
# include "clipspace/view_rh_zo.h"
|
||||
# include "clipspace/view_rh_no.h"
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief set up perspective peprojection matrix
|
||||
*
|
||||
@@ -68,22 +103,15 @@ glm_frustum(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
float rl, tb, fn, nv;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
rl = 1.0f / (right - left);
|
||||
tb = 1.0f / (top - bottom);
|
||||
fn =-1.0f / (farZ - nearZ);
|
||||
nv = 2.0f * nearZ;
|
||||
|
||||
dest[0][0] = nv * rl;
|
||||
dest[1][1] = nv * tb;
|
||||
dest[2][0] = (right + left) * rl;
|
||||
dest[2][1] = (top + bottom) * tb;
|
||||
dest[2][2] = (farZ + nearZ) * fn;
|
||||
dest[2][3] =-1.0f;
|
||||
dest[3][2] = farZ * nv * fn;
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_frustum_lh_zo(left, right, bottom, top, nearZ, farZ, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_frustum_lh_no(left, right, bottom, top, nearZ, farZ, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_frustum_rh_zo(left, right, bottom, top, nearZ, farZ, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_frustum_rh_no(left, right, bottom, top, nearZ, farZ, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -103,21 +131,15 @@ glm_ortho(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
float rl, tb, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
rl = 1.0f / (right - left);
|
||||
tb = 1.0f / (top - bottom);
|
||||
fn =-1.0f / (farZ - nearZ);
|
||||
|
||||
dest[0][0] = 2.0f * rl;
|
||||
dest[1][1] = 2.0f * tb;
|
||||
dest[2][2] = 2.0f * fn;
|
||||
dest[3][0] =-(right + left) * rl;
|
||||
dest[3][1] =-(top + bottom) * tb;
|
||||
dest[3][2] = (farZ + nearZ) * fn;
|
||||
dest[3][3] = 1.0f;
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_ortho_lh_zo(left, right, bottom, top, nearZ, farZ, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_ortho_lh_no(left, right, bottom, top, nearZ, farZ, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_ortho_rh_zo(left, right, bottom, top, nearZ, farZ, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_ortho_rh_no(left, right, bottom, top, nearZ, farZ, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -131,10 +153,15 @@ glm_ortho(float left, float right,
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb(vec3 box[2], mat4 dest) {
|
||||
glm_ortho(box[0][0], box[1][0],
|
||||
box[0][1], box[1][1],
|
||||
-box[1][2], -box[0][2],
|
||||
dest);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_ortho_aabb_lh_zo(box, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_ortho_aabb_lh_no(box, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_ortho_aabb_rh_zo(box, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_ortho_aabb_rh_no(box, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -149,10 +176,15 @@ glm_ortho_aabb(vec3 box[2], mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_p(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho(box[0][0] - padding, box[1][0] + padding,
|
||||
box[0][1] - padding, box[1][1] + padding,
|
||||
-(box[1][2] + padding), -(box[0][2] - padding),
|
||||
dest);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_ortho_aabb_p_lh_zo(box, padding, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_ortho_aabb_p_lh_no(box, padding, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_ortho_aabb_p_rh_zo(box, padding, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_ortho_aabb_p_rh_no(box, padding, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -167,10 +199,15 @@ glm_ortho_aabb_p(vec3 box[2], float padding, mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho(box[0][0], box[1][0],
|
||||
box[0][1], box[1][1],
|
||||
-(box[1][2] + padding), -(box[0][2] - padding),
|
||||
dest);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_ortho_aabb_pz_lh_zo(box, padding, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_ortho_aabb_pz_lh_no(box, padding, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_ortho_aabb_pz_rh_zo(box, padding, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_ortho_aabb_pz_rh_no(box, padding, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -182,14 +219,15 @@ glm_ortho_aabb_pz(vec3 box[2], float padding, mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_default(float aspect, mat4 dest) {
|
||||
if (aspect >= 1.0f) {
|
||||
glm_ortho(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest);
|
||||
return;
|
||||
}
|
||||
|
||||
aspect = 1.0f / aspect;
|
||||
|
||||
glm_ortho(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_ortho_default_lh_zo(aspect, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_ortho_default_lh_no(aspect, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_ortho_default_rh_zo(aspect, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_ortho_default_rh_no(aspect, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -202,24 +240,15 @@ glm_ortho_default(float aspect, mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_default_s(float aspect, float size, mat4 dest) {
|
||||
if (aspect >= 1.0f) {
|
||||
glm_ortho(-size * aspect,
|
||||
size * aspect,
|
||||
-size,
|
||||
size,
|
||||
-size - 100.0f,
|
||||
size + 100.0f,
|
||||
dest);
|
||||
return;
|
||||
}
|
||||
|
||||
glm_ortho(-size,
|
||||
size,
|
||||
-size / aspect,
|
||||
size / aspect,
|
||||
-size - 100.0f,
|
||||
size + 100.0f,
|
||||
dest);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_ortho_default_s_lh_zo(aspect, size, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_ortho_default_s_lh_no(aspect, size, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_ortho_default_s_rh_zo(aspect, size, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_ortho_default_s_rh_no(aspect, size, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -234,18 +263,15 @@ glm_ortho_default_s(float aspect, float size, mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest) {
|
||||
float f, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
f = 1.0f / tanf(fovy * 0.5f);
|
||||
fn = 1.0f / (nearZ - farZ);
|
||||
|
||||
dest[0][0] = f / aspect;
|
||||
dest[1][1] = f;
|
||||
dest[2][2] = (nearZ + farZ) * fn;
|
||||
dest[2][3] =-1.0f;
|
||||
dest[3][2] = 2.0f * nearZ * farZ * fn;
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_perspective_lh_zo(fovy, aspect, nearZ, farZ, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_perspective_lh_no(fovy, aspect, nearZ, farZ, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_perspective_rh_zo(fovy, aspect, nearZ, farZ, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_perspective_rh_no(fovy, aspect, nearZ, farZ, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -259,17 +285,15 @@ glm_perspective(float fovy, float aspect, float nearZ, float farZ, mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_move_far(mat4 proj, float deltaFar) {
|
||||
float fn, farZ, nearZ, p22, p32;
|
||||
|
||||
p22 = proj[2][2];
|
||||
p32 = proj[3][2];
|
||||
|
||||
nearZ = p32 / (p22 - 1.0f);
|
||||
farZ = p32 / (p22 + 1.0f) + deltaFar;
|
||||
fn = 1.0f / (nearZ - farZ);
|
||||
|
||||
proj[2][2] = (nearZ + farZ) * fn;
|
||||
proj[3][2] = 2.0f * nearZ * farZ * fn;
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_persp_move_far_lh_zo(proj, deltaFar);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_persp_move_far_lh_no(proj, deltaFar);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_persp_move_far_rh_zo(proj, deltaFar);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_persp_move_far_rh_no(proj, deltaFar);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -282,7 +306,15 @@ glm_persp_move_far(mat4 proj, float deltaFar) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_default(float aspect, mat4 dest) {
|
||||
glm_perspective(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_perspective_default_lh_zo(aspect, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_perspective_default_lh_no(aspect, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_perspective_default_rh_zo(aspect, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_perspective_default_rh_no(aspect, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -316,28 +348,11 @@ glm_perspective_resize(float aspect, mat4 proj) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
CGLM_ALIGN(8) vec3 f, u, s;
|
||||
|
||||
glm_vec3_sub(center, eye, f);
|
||||
glm_vec3_normalize(f);
|
||||
|
||||
glm_vec3_crossn(f, up, s);
|
||||
glm_vec3_cross(s, f, u);
|
||||
|
||||
dest[0][0] = s[0];
|
||||
dest[0][1] = u[0];
|
||||
dest[0][2] =-f[0];
|
||||
dest[1][0] = s[1];
|
||||
dest[1][1] = u[1];
|
||||
dest[1][2] =-f[1];
|
||||
dest[2][0] = s[2];
|
||||
dest[2][1] = u[2];
|
||||
dest[2][2] =-f[2];
|
||||
dest[3][0] =-glm_vec3_dot(s, eye);
|
||||
dest[3][1] =-glm_vec3_dot(u, eye);
|
||||
dest[3][2] = glm_vec3_dot(f, eye);
|
||||
dest[0][3] = dest[1][3] = dest[2][3] = 0.0f;
|
||||
dest[3][3] = 1.0f;
|
||||
#if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_LH
|
||||
glm_lookat_lh(eye, center, up, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_RH
|
||||
glm_lookat_rh(eye, center, up, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -357,9 +372,11 @@ glm_lookat(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
CGLM_ALIGN(8) vec3 target;
|
||||
glm_vec3_add(eye, dir, target);
|
||||
glm_lookat(eye, target, up, dest);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_LH
|
||||
glm_look_lh(eye, dir, up, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_RH
|
||||
glm_look_rh(eye, dir, up, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -375,9 +392,11 @@ glm_look(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_anyup(vec3 eye, vec3 dir, mat4 dest) {
|
||||
CGLM_ALIGN(8) vec3 up;
|
||||
glm_vec3_ortho(dir, up);
|
||||
glm_look(eye, dir, up, dest);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_LH
|
||||
glm_look_anyup_lh(eye, dir, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL & CGLM_CLIP_CONTROL_RH
|
||||
glm_look_anyup_rh(eye, dir, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -397,28 +416,15 @@ glm_persp_decomp(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right) {
|
||||
float m00, m11, m20, m21, m22, m32, n, f;
|
||||
float n_m11, n_m00;
|
||||
|
||||
m00 = proj[0][0];
|
||||
m11 = proj[1][1];
|
||||
m20 = proj[2][0];
|
||||
m21 = proj[2][1];
|
||||
m22 = proj[2][2];
|
||||
m32 = proj[3][2];
|
||||
|
||||
n = m32 / (m22 - 1.0f);
|
||||
f = m32 / (m22 + 1.0f);
|
||||
|
||||
n_m11 = n / m11;
|
||||
n_m00 = n / m00;
|
||||
|
||||
*nearZ = n;
|
||||
*farZ = f;
|
||||
*bottom = n_m11 * (m21 - 1.0f);
|
||||
*top = n_m11 * (m21 + 1.0f);
|
||||
*left = n_m00 * (m20 - 1.0f);
|
||||
*right = n_m00 * (m20 + 1.0f);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_persp_decomp_lh_zo(proj, nearZ, farZ, top, bottom, left, right);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_persp_decomp_lh_no(proj, nearZ, farZ, top, bottom, left, right);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_persp_decomp_rh_zo(proj, nearZ, farZ, top, bottom, left, right);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_persp_decomp_rh_no(proj, nearZ, farZ, top, bottom, left, right);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -431,8 +437,15 @@ glm_persp_decomp(mat4 proj,
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decompv(mat4 proj, float dest[6]) {
|
||||
glm_persp_decomp(proj, &dest[0], &dest[1], &dest[2],
|
||||
&dest[3], &dest[4], &dest[5]);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_persp_decompv_lh_zo(proj, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_persp_decompv_lh_no(proj, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_persp_decompv_rh_zo(proj, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_persp_decompv_rh_no(proj, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -448,14 +461,15 @@ void
|
||||
glm_persp_decomp_x(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right) {
|
||||
float nearZ, m20, m00;
|
||||
|
||||
m00 = proj[0][0];
|
||||
m20 = proj[2][0];
|
||||
|
||||
nearZ = proj[3][2] / (proj[3][3] - 1.0f);
|
||||
*left = nearZ * (m20 - 1.0f) / m00;
|
||||
*right = nearZ * (m20 + 1.0f) / m00;
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_persp_decomp_x_lh_zo(proj, left, right);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_persp_decomp_x_lh_no(proj, left, right);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_persp_decomp_x_rh_zo(proj, left, right);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_persp_decomp_x_rh_no(proj, left, right);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -471,14 +485,15 @@ void
|
||||
glm_persp_decomp_y(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom) {
|
||||
float nearZ, m21, m11;
|
||||
|
||||
m21 = proj[2][1];
|
||||
m11 = proj[1][1];
|
||||
|
||||
nearZ = proj[3][2] / (proj[3][3] - 1.0f);
|
||||
*bottom = nearZ * (m21 - 1) / m11;
|
||||
*top = nearZ * (m21 + 1) / m11;
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_persp_decomp_y_lh_zo(proj, top, bottom);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_persp_decomp_y_lh_no(proj, top, bottom);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_persp_decomp_y_rh_zo(proj, top, bottom);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_persp_decomp_y_rh_no(proj, top, bottom);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -492,13 +507,15 @@ glm_persp_decomp_y(mat4 proj,
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_z(mat4 proj, float * __restrict nearZ, float * __restrict farZ) {
|
||||
float m32, m22;
|
||||
|
||||
m32 = proj[3][2];
|
||||
m22 = proj[2][2];
|
||||
|
||||
*nearZ = m32 / (m22 - 1.0f);
|
||||
*farZ = m32 / (m22 + 1.0f);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_persp_decomp_z_lh_zo(proj, nearZ, farZ);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_persp_decomp_z_lh_no(proj, nearZ, farZ);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_persp_decomp_z_rh_zo(proj, nearZ, farZ);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_persp_decomp_z_rh_no(proj, nearZ, farZ);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -510,7 +527,15 @@ glm_persp_decomp_z(mat4 proj, float * __restrict nearZ, float * __restrict farZ)
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_far(mat4 proj, float * __restrict farZ) {
|
||||
*farZ = proj[3][2] / (proj[2][2] + 1.0f);
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_persp_decomp_far_lh_zo(proj, farZ);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_persp_decomp_far_lh_no(proj, farZ);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_persp_decomp_far_rh_zo(proj, farZ);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_persp_decomp_far_rh_no(proj, farZ);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -522,32 +547,15 @@ glm_persp_decomp_far(mat4 proj, float * __restrict farZ) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_near(mat4 proj, float * __restrict nearZ) {
|
||||
*nearZ = proj[3][2] / (proj[2][2] - 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns field of view angle along the Y-axis (in radians)
|
||||
*
|
||||
* if you need to degrees, use glm_deg to convert it or use this:
|
||||
* fovy_deg = glm_deg(glm_persp_fovy(projMatrix))
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_fovy(mat4 proj) {
|
||||
return 2.0f * atanf(1.0f / proj[1][1]);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns aspect ratio of perspective projection
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_aspect(mat4 proj) {
|
||||
return proj[1][1] / proj[0][0];
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_persp_decomp_near_lh_zo(proj, nearZ);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_persp_decomp_near_lh_no(proj, nearZ);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_persp_decomp_near_rh_zo(proj, nearZ);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_persp_decomp_near_rh_no(proj, nearZ);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -560,17 +568,15 @@ glm_persp_aspect(mat4 proj) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_sizes(mat4 proj, float fovy, vec4 dest) {
|
||||
float t, a, nearZ, farZ;
|
||||
|
||||
t = 2.0f * tanf(fovy * 0.5f);
|
||||
a = glm_persp_aspect(proj);
|
||||
|
||||
glm_persp_decomp_z(proj, &nearZ, &farZ);
|
||||
|
||||
dest[1] = t * nearZ;
|
||||
dest[3] = t * farZ;
|
||||
dest[0] = a * dest[1];
|
||||
dest[2] = a * dest[3];
|
||||
#if CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_ZO
|
||||
glm_persp_sizes_lh_zo(proj, fovy, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_LH_NO
|
||||
glm_persp_sizes_lh_no(proj, fovy, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_ZO
|
||||
glm_persp_sizes_rh_zo(proj, fovy, dest);
|
||||
#elif CGLM_CONFIG_CLIP_CONTROL == CGLM_CLIP_CONTROL_RH_NO
|
||||
glm_persp_sizes_rh_no(proj, fovy, dest);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* cglm_vcam_h */
|
||||
#endif /* cglm_cam_h */
|
||||
|
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_perspective_lh_no(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_cam_lh_no_h
|
||||
#define cglm_cam_lh_no_h
|
||||
|
||||
#include "common.h"
|
||||
#include "plane.h"
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix with a left-hand coordinate
|
||||
* system and a clip-space of [-1, 1]
|
||||
*
|
||||
* @param[in] fovy field of view angle
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] nearVal near clipping plane
|
||||
* @param[in] farVal far clipping planes
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_lh_no(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
/* Impl follows glm::perspectiveLH_NO in glm/ext/matrix_clip_space.inl */
|
||||
float fl, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
fl = 1.0f / tanf(fovy * 0.5f);
|
||||
fn = 1.0f / (farVal - nearVal);
|
||||
|
||||
dest[0][0] = fl / aspect;
|
||||
dest[1][1] = fl;
|
||||
dest[2][2] = (farVal + nearVal) * fn;
|
||||
dest[2][3] = 1.0f;
|
||||
dest[3][2] = -2.0f * farVal * nearVal * fn;
|
||||
}
|
||||
|
||||
#endif /*cglm_cam_lh_no_h*/
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_perspective_lh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_cam_lh_zo_h
|
||||
#define cglm_cam_lh_zo_h
|
||||
|
||||
#include "common.h"
|
||||
#include "plane.h"
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix with a left-hand coordinate
|
||||
* system (suitable, apparently, for DirectX and Metal) and a clip-space with
|
||||
* depth values from zero to one.
|
||||
*
|
||||
* @param[in] fovy field of view angle
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] nearVal near clipping plane
|
||||
* @param[in] farVal far clipping planes
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_lh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
/* Impl follows glm::perspectiveLH_ZO in glm/ext/matrix_clip_space.inl */
|
||||
float fl, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
fl = 1.0f / tanf(fovy * 0.5f);
|
||||
fn = 1.0f / (farVal - nearVal);
|
||||
|
||||
dest[0][0] = fl / aspect;
|
||||
dest[1][1] = fl;
|
||||
dest[2][2] = farVal * fn;
|
||||
dest[2][3] = 1.0f;
|
||||
dest[3][2] = -farVal * nearVal * fn;
|
||||
}
|
||||
|
||||
#endif /*cglm_cam_lh_zo_h*/
|
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_perspective_rh_no(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_cam_rh_no_h
|
||||
#define cglm_cam_rh_no_h
|
||||
|
||||
#include "common.h"
|
||||
#include "plane.h"
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix with a right-hand coordinate
|
||||
* system and a clip space of [-1, 1].
|
||||
*
|
||||
* @param[in] fovy field of view angle
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] nearVal near clipping plane
|
||||
* @param[in] farVal far clipping planes
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_rh_no(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
/* Impl follows glm::perspectiveRH_NO in glm/ext/matrix_clip_space.inl */
|
||||
float fl, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
fl = 1.0f / tanf(fovy * 0.5f);
|
||||
fn = 1.0f / (farVal - nearVal);
|
||||
|
||||
dest[0][0] = fl / aspect;
|
||||
dest[1][1] = fl;
|
||||
dest[2][2] = -(farVal + nearVal) * fn;
|
||||
dest[2][3] = -1.0f;
|
||||
dest[3][2] = -2.0f * farVal * nearVal * fn;
|
||||
}
|
||||
|
||||
#endif /*cglm_cam_rh_no_h*/
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_perspective_rh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_cam_rh_zo_h
|
||||
#define cglm_cam_rh_zo_h
|
||||
|
||||
#include "common.h"
|
||||
#include "plane.h"
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix with a right-hand coordinate
|
||||
* system (suitable for Vulkan) and a clip-space with depth values from zero
|
||||
* to one.
|
||||
*
|
||||
* @param[in] fovy field of view angle
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] nearVal near clipping plane
|
||||
* @param[in] farVal far clipping planes
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_rh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
/* Impl follows glm::perspectiveRH_ZO in glm/ext/matrix_clip_space.inl */
|
||||
float fl, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
fl = 1.0f / tanf(fovy * 0.5f);
|
||||
fn = 1.0f / (farVal - nearVal);
|
||||
|
||||
dest[0][0] = fl / aspect;
|
||||
dest[1][1] = fl;
|
||||
dest[2][2] = -farVal * fn;
|
||||
dest[2][3] = -1.0f;
|
||||
dest[3][2] = -farVal * nearVal * fn;
|
||||
}
|
||||
|
||||
#endif /*cglm_cam_rh_zo_h*/
|
@@ -17,10 +17,6 @@
|
||||
#include "mat2.h"
|
||||
#include "affine.h"
|
||||
#include "cam.h"
|
||||
#include "cam_lh_zo.h"
|
||||
#include "cam_rh_zo.h"
|
||||
#include "cam_lh_no.h"
|
||||
#include "cam_rh_no.h"
|
||||
#include "frustum.h"
|
||||
#include "quat.h"
|
||||
#include "euler.h"
|
||||
|
182
include/cglm/clipspace/ortho_lh_no.h
Normal file
182
include/cglm/clipspace/ortho_lh_no.h
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_ortho_lh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_lh_no(vec3 box[2], mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_p_lh_no(vec3 box[2],
|
||||
float padding,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_pz_lh_no(vec3 box[2],
|
||||
float padding,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_default_lh_no(float aspect,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_default_s_lh_no(float aspect,
|
||||
float size,
|
||||
mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_ortho_lh_no_h
|
||||
#define cglm_ortho_lh_no_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] left viewport.left
|
||||
* @param[in] right viewport.right
|
||||
* @param[in] bottom viewport.bottom
|
||||
* @param[in] top viewport.top
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping plane
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_lh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
float rl, tb, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
rl = 1.0f / (right - left);
|
||||
tb = 1.0f / (top - bottom);
|
||||
fn =-1.0f / (farZ - nearZ);
|
||||
|
||||
dest[0][0] = 2.0f * rl;
|
||||
dest[1][1] = 2.0f * tb;
|
||||
dest[2][2] =-2.0f * fn;
|
||||
dest[3][0] =-(right + left) * rl;
|
||||
dest[3][1] =-(top + bottom) * tb;
|
||||
dest[3][2] = (farZ + nearZ) * fn;
|
||||
dest[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_lh_no(vec3 box[2], mat4 dest) {
|
||||
glm_ortho_lh_no(box[0][0], box[1][0],
|
||||
box[0][1], box[1][1],
|
||||
-box[1][2], -box[0][2],
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[in] padding padding
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_p_lh_no(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_lh_no(box[0][0] - padding, box[1][0] + padding,
|
||||
box[0][1] - padding, box[1][1] + padding,
|
||||
-(box[1][2] + padding), -(box[0][2] - padding),
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[in] padding padding for near and far
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_pz_lh_no(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_lh_no(box[0][0], box[1][0],
|
||||
box[0][1], box[1][1],
|
||||
-(box[1][2] + padding), -(box[0][2] - padding),
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up unit orthographic projection matrix
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ration ( width / height )
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_default_lh_no(float aspect, mat4 dest) {
|
||||
if (aspect >= 1.0f) {
|
||||
glm_ortho_lh_no(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest);
|
||||
return;
|
||||
}
|
||||
|
||||
aspect = 1.0f / aspect;
|
||||
|
||||
glm_ortho_lh_no(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix with given CUBE size
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] size cube size
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_default_s_lh_no(float aspect, float size, mat4 dest) {
|
||||
if (aspect >= 1.0f) {
|
||||
glm_ortho_lh_no(-size * aspect,
|
||||
size * aspect,
|
||||
-size,
|
||||
size,
|
||||
-size - 100.0f,
|
||||
size + 100.0f,
|
||||
dest);
|
||||
return;
|
||||
}
|
||||
|
||||
glm_ortho_lh_no(-size,
|
||||
size,
|
||||
-size / aspect,
|
||||
size / aspect,
|
||||
-size - 100.0f,
|
||||
size + 100.0f,
|
||||
dest);
|
||||
}
|
||||
|
||||
#endif /*cglm_ortho_lh_no_h*/
|
180
include/cglm/clipspace/ortho_lh_zo.h
Normal file
180
include/cglm/clipspace/ortho_lh_zo.h
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_ortho_lh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_lh_zo(vec3 box[2], mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_p_lh_zo(vec3 box[2],
|
||||
float padding,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_pz_lh_zo(vec3 box[2],
|
||||
float padding,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_default_lh_zo(float aspect,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_default_s_lh_zo(float aspect,
|
||||
float size,
|
||||
mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_ortho_lh_zo_h
|
||||
#define cglm_ortho_lh_zo_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix with a left-hand coordinate
|
||||
* system and a clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] left viewport.left
|
||||
* @param[in] right viewport.right
|
||||
* @param[in] bottom viewport.bottom
|
||||
* @param[in] top viewport.top
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping plane
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_lh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
float rl, tb, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
rl = 1.0f / (right - left);
|
||||
tb = 1.0f / (top - bottom);
|
||||
fn =-1.0f / (farZ - nearZ);
|
||||
|
||||
dest[0][0] = 2.0f * rl;
|
||||
dest[1][1] = 2.0f * tb;
|
||||
dest[2][2] =-fn;
|
||||
dest[3][0] =-(right + left) * rl;
|
||||
dest[3][1] =-(top + bottom) * tb;
|
||||
dest[3][2] = nearZ * fn;
|
||||
dest[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a left-hand coordinate system and a clip-space with depth
|
||||
* values from zero to one.
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_lh_zo(vec3 box[2], mat4 dest) {
|
||||
glm_ortho_lh_zo(box[0][0], box[1][0],
|
||||
box[0][1], box[1][1],
|
||||
-box[1][2], -box[0][2],
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a left-hand coordinate system and a clip-space with depth
|
||||
* values from zero to one.
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[in] padding padding
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_p_lh_zo(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_lh_zo(box[0][0] - padding, box[1][0] + padding,
|
||||
box[0][1] - padding, box[1][1] + padding,
|
||||
-(box[1][2] + padding), -(box[0][2] - padding),
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a left-hand coordinate system and a clip-space with depth
|
||||
* values from zero to one.
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[in] padding padding for near and far
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_pz_lh_zo(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_lh_zo(box[0][0], box[1][0],
|
||||
box[0][1], box[1][1],
|
||||
-(box[1][2] + padding), -(box[0][2] - padding),
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up unit orthographic projection matrix with a left-hand
|
||||
* coordinate system and a clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ration ( width / height )
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_default_lh_zo(float aspect, mat4 dest) {
|
||||
if (aspect >= 1.0f) {
|
||||
glm_ortho_lh_zo(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest);
|
||||
return;
|
||||
}
|
||||
|
||||
aspect = 1.0f / aspect;
|
||||
|
||||
glm_ortho_lh_zo(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix with given CUBE size
|
||||
* with a left-hand coordinate system and a clip-space with depth
|
||||
* values from zero to one.
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] size cube size
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_default_s_lh_zo(float aspect, float size, mat4 dest) {
|
||||
if (aspect >= 1.0f) {
|
||||
glm_ortho_lh_zo(-size * aspect,
|
||||
size * aspect,
|
||||
-size,
|
||||
size,
|
||||
-size - 100.0f,
|
||||
size + 100.0f,
|
||||
dest);
|
||||
return;
|
||||
}
|
||||
|
||||
glm_ortho_lh_zo(-size,
|
||||
size,
|
||||
-size / aspect,
|
||||
size / aspect,
|
||||
-size - 100.0f,
|
||||
size + 100.0f,
|
||||
dest);
|
||||
}
|
||||
|
||||
#endif /*cglm_ortho_lh_zo_h*/
|
182
include/cglm/clipspace/ortho_rh_no.h
Normal file
182
include/cglm/clipspace/ortho_rh_no.h
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_ortho_rh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_rh_no(vec3 box[2], mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_p_rh_no(vec3 box[2],
|
||||
float padding,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_pz_rh_no(vec3 box[2],
|
||||
float padding,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_default_rh_no(float aspect,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_default_s_rh_no(float aspect,
|
||||
float size,
|
||||
mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_ortho_rh_no_h
|
||||
#define cglm_ortho_rh_no_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] left viewport.left
|
||||
* @param[in] right viewport.right
|
||||
* @param[in] bottom viewport.bottom
|
||||
* @param[in] top viewport.top
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping plane
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_rh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
float rl, tb, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
rl = 1.0f / (right - left);
|
||||
tb = 1.0f / (top - bottom);
|
||||
fn =-1.0f / (farZ - nearZ);
|
||||
|
||||
dest[0][0] = 2.0f * rl;
|
||||
dest[1][1] = 2.0f * tb;
|
||||
dest[2][2] = 2.0f * fn;
|
||||
dest[3][0] =-(right + left) * rl;
|
||||
dest[3][1] =-(top + bottom) * tb;
|
||||
dest[3][2] = (farZ + nearZ) * fn;
|
||||
dest[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_rh_no(vec3 box[2], mat4 dest) {
|
||||
glm_ortho_rh_no(box[0][0], box[1][0],
|
||||
box[0][1], box[1][1],
|
||||
-box[1][2], -box[0][2],
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[in] padding padding
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_p_rh_no(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_rh_no(box[0][0] - padding, box[1][0] + padding,
|
||||
box[0][1] - padding, box[1][1] + padding,
|
||||
-(box[1][2] + padding), -(box[0][2] - padding),
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[in] padding padding for near and far
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_pz_rh_no(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_rh_no(box[0][0], box[1][0],
|
||||
box[0][1], box[1][1],
|
||||
-(box[1][2] + padding), -(box[0][2] - padding),
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up unit orthographic projection matrix
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ration ( width / height )
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_default_rh_no(float aspect, mat4 dest) {
|
||||
if (aspect >= 1.0f) {
|
||||
glm_ortho_rh_no(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest);
|
||||
return;
|
||||
}
|
||||
|
||||
aspect = 1.0f / aspect;
|
||||
|
||||
glm_ortho_rh_no(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix with given CUBE size
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] size cube size
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_default_s_rh_no(float aspect, float size, mat4 dest) {
|
||||
if (aspect >= 1.0f) {
|
||||
glm_ortho_rh_no(-size * aspect,
|
||||
size * aspect,
|
||||
-size,
|
||||
size,
|
||||
-size - 100.0f,
|
||||
size + 100.0f,
|
||||
dest);
|
||||
return;
|
||||
}
|
||||
|
||||
glm_ortho_rh_no(-size,
|
||||
size,
|
||||
-size / aspect,
|
||||
size / aspect,
|
||||
-size - 100.0f,
|
||||
size + 100.0f,
|
||||
dest);
|
||||
}
|
||||
|
||||
#endif /*cglm_ortho_rh_no_h*/
|
180
include/cglm/clipspace/ortho_rh_zo.h
Normal file
180
include/cglm/clipspace/ortho_rh_zo.h
Normal file
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_ortho_rh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_rh_zo(vec3 box[2], mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_p_rh_zo(vec3 box[2],
|
||||
float padding,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_aabb_pz_rh_zo(vec3 box[2],
|
||||
float padding,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_default_rh_zo(float aspect,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_ortho_default_s_rh_zo(float aspect,
|
||||
float size,
|
||||
mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_ortho_rh_zo_h
|
||||
#define cglm_ortho_rh_zo_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix with a right-hand coordinate
|
||||
* system and a clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] left viewport.left
|
||||
* @param[in] right viewport.right
|
||||
* @param[in] bottom viewport.bottom
|
||||
* @param[in] top viewport.top
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping plane
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_rh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
float rl, tb, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
rl = 1.0f / (right - left);
|
||||
tb = 1.0f / (top - bottom);
|
||||
fn =-1.0f / (farZ - nearZ);
|
||||
|
||||
dest[0][0] = 2.0f * rl;
|
||||
dest[1][1] = 2.0f * tb;
|
||||
dest[2][2] = fn;
|
||||
dest[3][0] =-(right + left) * rl;
|
||||
dest[3][1] =-(top + bottom) * tb;
|
||||
dest[3][2] = nearZ * fn;
|
||||
dest[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a right-hand coordinate system and a clip-space with depth
|
||||
* values from zero to one.
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_rh_zo(vec3 box[2], mat4 dest) {
|
||||
glm_ortho_rh_zo(box[0][0], box[1][0],
|
||||
box[0][1], box[1][1],
|
||||
-box[1][2], -box[0][2],
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a right-hand coordinate system and a clip-space with depth
|
||||
* values from zero to one.
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[in] padding padding
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_p_rh_zo(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_rh_zo(box[0][0] - padding, box[1][0] + padding,
|
||||
box[0][1] - padding, box[1][1] + padding,
|
||||
-(box[1][2] + padding), -(box[0][2] - padding),
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix using bounding box
|
||||
* with a right-hand coordinate system and a clip-space with depth
|
||||
* values from zero to one.
|
||||
*
|
||||
* bounding box (AABB) must be in view space
|
||||
*
|
||||
* @param[in] box AABB
|
||||
* @param[in] padding padding for near and far
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_aabb_pz_rh_zo(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_rh_zo(box[0][0], box[1][0],
|
||||
box[0][1], box[1][1],
|
||||
-(box[1][2] + padding), -(box[0][2] - padding),
|
||||
dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up unit orthographic projection matrix with a right-hand
|
||||
* coordinate system and a clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ration ( width / height )
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_default_rh_zo(float aspect, mat4 dest) {
|
||||
if (aspect >= 1.0f) {
|
||||
glm_ortho_rh_zo(-aspect, aspect, -1.0f, 1.0f, -100.0f, 100.0f, dest);
|
||||
return;
|
||||
}
|
||||
|
||||
aspect = 1.0f / aspect;
|
||||
|
||||
glm_ortho_rh_zo(-1.0f, 1.0f, -aspect, aspect, -100.0f, 100.0f, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up orthographic projection matrix with given CUBE size
|
||||
* with a right-hand coordinate system and a clip-space with depth
|
||||
* values from zero to one.
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] size cube size
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_ortho_default_s_rh_zo(float aspect, float size, mat4 dest) {
|
||||
if (aspect >= 1.0f) {
|
||||
glm_ortho_rh_zo(-size * aspect,
|
||||
size * aspect,
|
||||
-size,
|
||||
size,
|
||||
-size - 100.0f,
|
||||
size + 100.0f,
|
||||
dest);
|
||||
return;
|
||||
}
|
||||
|
||||
glm_ortho_rh_zo(-size,
|
||||
size,
|
||||
-size / aspect,
|
||||
size / aspect,
|
||||
-size - 100.0f,
|
||||
size + 100.0f,
|
||||
dest);
|
||||
}
|
||||
|
||||
#endif /*cglm_ortho_rh_zo_h*/
|
48
include/cglm/clipspace/persp.h
Normal file
48
include/cglm/clipspace/persp.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_persp_decomp_far(mat4 proj, float *farZ)
|
||||
CGLM_INLINE float glm_persp_fovy(mat4 proj)
|
||||
CGLM_INLINE float glm_persp_aspect(mat4 proj)
|
||||
CGLM_INLINE void glm_persp_sizes(mat4 proj, float fovy, vec4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_persp_h
|
||||
#define cglm_persp_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
#include "../mat4.h"
|
||||
|
||||
/*!
|
||||
* @brief returns field of view angle along the Y-axis (in radians)
|
||||
*
|
||||
* if you need to degrees, use glm_deg to convert it or use this:
|
||||
* fovy_deg = glm_deg(glm_persp_fovy(projMatrix))
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_fovy(mat4 proj) {
|
||||
return 2.0f * atanf(1.0f / proj[1][1]);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns aspect ratio of perspective projection
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_aspect(mat4 proj) {
|
||||
return proj[1][1] / proj[0][0];
|
||||
}
|
||||
|
||||
#endif /* cglm_persp_h */
|
396
include/cglm/clipspace/persp_lh_no.h
Normal file
396
include/cglm/clipspace/persp_lh_no.h
Normal file
@@ -0,0 +1,396 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_frustum_lh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_lh_no(float fovy,
|
||||
float aspect,
|
||||
float nearZ,
|
||||
float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_default_lh_no(float aspect, mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_resize_lh_no(float aspect, mat4 proj)
|
||||
CGLM_INLINE void glm_persp_move_far_lh_no(mat4 proj,
|
||||
float deltaFar)
|
||||
CGLM_INLINE void glm_persp_decomp_lh_no(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom,
|
||||
float * __restrict left,
|
||||
float * __restrict right)
|
||||
CGLM_INLINE void glm_persp_decompv_lh_no(mat4 proj,
|
||||
float dest[6])
|
||||
CGLM_INLINE void glm_persp_decomp_x_lh_no(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right)
|
||||
CGLM_INLINE void glm_persp_decomp_y_lh_no(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom)
|
||||
CGLM_INLINE void glm_persp_decomp_z_lh_no(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ)
|
||||
CGLM_INLINE void glm_persp_decomp_far_lh_no(mat4 proj, float * __restrict farZ)
|
||||
CGLM_INLINE void glm_persp_decomp_near_lh_no(mat4 proj, float * __restrict nearZ)
|
||||
CGLM_INLINE void glm_persp_sizes_lh_no(mat4 proj, float fovy, vec4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_persp_lh_no_h
|
||||
#define cglm_persp_lh_no_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
#include "persp.h"
|
||||
|
||||
/*!
|
||||
* @brief set up perspective peprojection matrix
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] left viewport.left
|
||||
* @param[in] right viewport.right
|
||||
* @param[in] bottom viewport.bottom
|
||||
* @param[in] top viewport.top
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping plane
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_frustum_lh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
float rl, tb, fn, nv;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
rl = 1.0f / (right - left);
|
||||
tb = 1.0f / (top - bottom);
|
||||
fn =-1.0f / (farZ - nearZ);
|
||||
nv = 2.0f * nearZ;
|
||||
|
||||
dest[0][0] = nv * rl;
|
||||
dest[1][1] = nv * tb;
|
||||
dest[2][0] = (right + left) * rl;
|
||||
dest[2][1] = (top + bottom) * tb;
|
||||
dest[2][2] =-(farZ + nearZ) * fn;
|
||||
dest[2][3] = 1.0f;
|
||||
dest[3][2] = farZ * nv * fn;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] fovy field of view angle
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping planes
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_lh_no(float fovy,
|
||||
float aspect,
|
||||
float nearZ,
|
||||
float farZ,
|
||||
mat4 dest) {
|
||||
float f, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
f = 1.0f / tanf(fovy * 0.5f);
|
||||
fn = 1.0f / (nearZ - farZ);
|
||||
|
||||
dest[0][0] = f / aspect;
|
||||
dest[1][1] = f;
|
||||
dest[2][2] =-(nearZ + farZ) * fn;
|
||||
dest[2][3] = 1.0f;
|
||||
dest[3][2] = 2.0f * nearZ * farZ * fn;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix with default near/far
|
||||
* and angle values with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_default_lh_no(float aspect, mat4 dest) {
|
||||
glm_perspective_lh_no(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief resize perspective matrix by aspect ratio ( width / height )
|
||||
* this makes very easy to resize proj matrix when window /viewport
|
||||
* resized with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in, out] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_resize_lh_no(float aspect, mat4 proj) {
|
||||
if (proj[0][0] == 0.0f)
|
||||
return;
|
||||
|
||||
proj[0][0] = proj[1][1] / aspect;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief extend perspective projection matrix's far distance
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* this function does not guarantee far >= near, be aware of that!
|
||||
*
|
||||
* @param[in, out] proj projection matrix to extend
|
||||
* @param[in] deltaFar distance from existing far (negative to shink)
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_move_far_lh_no(mat4 proj, float deltaFar) {
|
||||
float fn, farZ, nearZ, p22, p32;
|
||||
|
||||
p22 = -proj[2][2];
|
||||
p32 = proj[3][2];
|
||||
|
||||
nearZ = p32 / (p22 - 1.0f);
|
||||
farZ = p32 / (p22 + 1.0f) + deltaFar;
|
||||
fn = 1.0f / (nearZ - farZ);
|
||||
|
||||
proj[2][2] = -(farZ + nearZ) * fn;
|
||||
proj[3][2] = 2.0f * nearZ * farZ * fn;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes frustum values of perspective projection
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
* @param[out] farZ far
|
||||
* @param[out] top top
|
||||
* @param[out] bottom bottom
|
||||
* @param[out] left left
|
||||
* @param[out] right right
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_lh_no(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right) {
|
||||
float m00, m11, m20, m21, m22, m32, n, f;
|
||||
float n_m11, n_m00;
|
||||
|
||||
m00 = proj[0][0];
|
||||
m11 = proj[1][1];
|
||||
m20 = proj[2][0];
|
||||
m21 = proj[2][1];
|
||||
m22 =-proj[2][2];
|
||||
m32 = proj[3][2];
|
||||
|
||||
n = m32 / (m22 - 1.0f);
|
||||
f = m32 / (m22 + 1.0f);
|
||||
|
||||
n_m11 = n / m11;
|
||||
n_m00 = n / m00;
|
||||
|
||||
*nearZ = n;
|
||||
*farZ = f;
|
||||
*bottom = n_m11 * (m21 - 1.0f);
|
||||
*top = n_m11 * (m21 + 1.0f);
|
||||
*left = n_m00 * (m20 - 1.0f);
|
||||
*right = n_m00 * (m20 + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes frustum values of perspective projection
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
* this makes easy to get all values at once
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] dest array
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decompv_lh_no(mat4 proj, float dest[6]) {
|
||||
glm_persp_decomp_lh_no(proj, &dest[0], &dest[1], &dest[2],
|
||||
&dest[3], &dest[4], &dest[5]);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes left and right values of perspective projection
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
* x stands for x axis (left / right axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] left left
|
||||
* @param[out] right right
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_x_lh_no(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right) {
|
||||
float nearZ, m20, m00, m22;
|
||||
|
||||
m00 = proj[0][0];
|
||||
m20 = proj[2][0];
|
||||
m22 =-proj[2][2];
|
||||
|
||||
nearZ = proj[3][2] / (m22 - 1.0f);
|
||||
*left = nearZ * (m20 - 1.0f) / m00;
|
||||
*right = nearZ * (m20 + 1.0f) / m00;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes top and bottom values of perspective projection
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
* y stands for y axis (top / botom axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] top top
|
||||
* @param[out] bottom bottom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_y_lh_no(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom) {
|
||||
float nearZ, m21, m11, m22;
|
||||
|
||||
m21 = proj[2][1];
|
||||
m11 = proj[1][1];
|
||||
m22 =-proj[2][2];
|
||||
|
||||
nearZ = proj[3][2] / (m22 - 1.0f);
|
||||
*bottom = nearZ * (m21 - 1.0f) / m11;
|
||||
*top = nearZ * (m21 + 1.0f) / m11;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes near and far values of perspective projection
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
* z stands for z axis (near / far axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
* @param[out] farZ far
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_z_lh_no(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ) {
|
||||
float m32, m22;
|
||||
|
||||
m32 = proj[3][2];
|
||||
m22 =-proj[2][2];
|
||||
|
||||
*nearZ = m32 / (m22 - 1.0f);
|
||||
*farZ = m32 / (m22 + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes far value of perspective projection
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] farZ far
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_far_lh_no(mat4 proj, float * __restrict farZ) {
|
||||
*farZ = proj[3][2] / (-proj[2][2] + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes near value of perspective projection
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_near_lh_no(mat4 proj, float * __restrict nearZ) {
|
||||
*nearZ = proj[3][2] / (-proj[2][2] - 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns sizes of near and far planes of perspective projection
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[in] fovy fovy (see brief)
|
||||
* @param[out] dest sizes order: [Wnear, Hnear, Wfar, Hfar]
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_sizes_lh_no(mat4 proj, float fovy, vec4 dest) {
|
||||
float t, a, nearZ, farZ;
|
||||
|
||||
t = 2.0f * tanf(fovy * 0.5f);
|
||||
a = glm_persp_aspect(proj);
|
||||
|
||||
glm_persp_decomp_z_lh_no(proj, &nearZ, &farZ);
|
||||
|
||||
dest[1] = t * nearZ;
|
||||
dest[3] = t * farZ;
|
||||
dest[0] = a * dest[1];
|
||||
dest[2] = a * dest[3];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns field of view angle along the Y-axis (in radians)
|
||||
* with a left-hand coordinate system and a clip-space of [-1, 1].
|
||||
*
|
||||
* if you need to degrees, use glm_deg to convert it or use this:
|
||||
* fovy_deg = glm_deg(glm_persp_fovy(projMatrix))
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_fovy_lh_no(mat4 proj) {
|
||||
return glm_persp_fovy(proj);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns aspect ratio of perspective projection
|
||||
* with a left-hand coordinate system and a clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_aspect_lh_no(mat4 proj) {
|
||||
return glm_persp_aspect(proj);
|
||||
}
|
||||
|
||||
#endif /*cglm_cam_lh_no_h*/
|
388
include/cglm/clipspace/persp_lh_zo.h
Normal file
388
include/cglm/clipspace/persp_lh_zo.h
Normal file
@@ -0,0 +1,388 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_frustum_lh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_lh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearZ,
|
||||
float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_default_lh_zo(float aspect, mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_resize_lh_zo(float aspect, mat4 proj)
|
||||
CGLM_INLINE void glm_persp_move_far_lh_zo(mat4 proj,
|
||||
float deltaFar)
|
||||
CGLM_INLINE void glm_persp_decomp_lh_zo(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom,
|
||||
float * __restrict left,
|
||||
float * __restrict right)
|
||||
CGLM_INLINE void glm_persp_decompv_lh_zo(mat4 proj,
|
||||
float dest[6])
|
||||
CGLM_INLINE void glm_persp_decomp_x_lh_zo(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right)
|
||||
CGLM_INLINE void glm_persp_decomp_y_lh_zo(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom)
|
||||
CGLM_INLINE void glm_persp_decomp_z_lh_zo(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ)
|
||||
CGLM_INLINE void glm_persp_decomp_far_lh_zo(mat4 proj, float * __restrict farZ)
|
||||
CGLM_INLINE void glm_persp_decomp_near_lh_zo(mat4 proj, float * __restrict nearZ)
|
||||
CGLM_INLINE void glm_persp_sizes_lh_zo(mat4 proj, float fovy, vec4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_persp_lh_zo_h
|
||||
#define cglm_persp_lh_zo_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
#include "persp.h"
|
||||
|
||||
/*!
|
||||
* @brief set up perspective peprojection matrix with a left-hand coordinate
|
||||
* system and a clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] left viewport.left
|
||||
* @param[in] right viewport.right
|
||||
* @param[in] bottom viewport.bottom
|
||||
* @param[in] top viewport.top
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping plane
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_frustum_lh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
float rl, tb, fn, nv;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
rl = 1.0f / (right - left);
|
||||
tb = 1.0f / (top - bottom);
|
||||
fn =-1.0f / (farZ - nearZ);
|
||||
nv = 2.0f * nearZ;
|
||||
|
||||
dest[0][0] = nv * rl;
|
||||
dest[1][1] = nv * tb;
|
||||
dest[2][0] = (right + left) * rl;
|
||||
dest[2][1] = (top + bottom) * tb;
|
||||
dest[2][2] =-farZ * fn;
|
||||
dest[2][3] = 1.0f;
|
||||
dest[3][2] = farZ * nearZ * fn;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix with a left-hand coordinate
|
||||
* system and a clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] fovy field of view angle
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping planes
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_lh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearZ,
|
||||
float farZ,
|
||||
mat4 dest) {
|
||||
float f, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
f = 1.0f / tanf(fovy * 0.5f);
|
||||
fn = 1.0f / (nearZ - farZ);
|
||||
|
||||
dest[0][0] = f / aspect;
|
||||
dest[1][1] = f;
|
||||
dest[2][2] =-farZ * fn;
|
||||
dest[2][3] = 1.0f;
|
||||
dest[3][2] = nearZ * farZ * fn;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief extend perspective projection matrix's far distance with a
|
||||
* left-hand coordinate system and a clip-space with depth values
|
||||
* from zero to one.
|
||||
*
|
||||
* this function does not guarantee far >= near, be aware of that!
|
||||
*
|
||||
* @param[in, out] proj projection matrix to extend
|
||||
* @param[in] deltaFar distance from existing far (negative to shink)
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_move_far_lh_zo(mat4 proj, float deltaFar) {
|
||||
float fn, farZ, nearZ, p22, p32;
|
||||
|
||||
p22 = -proj[2][2];
|
||||
p32 = proj[3][2];
|
||||
|
||||
nearZ = p32 / p22;
|
||||
farZ = p32 / (p22 + 1.0f) + deltaFar;
|
||||
fn = 1.0f / (nearZ - farZ);
|
||||
|
||||
proj[2][2] = -farZ * fn;
|
||||
proj[3][2] = nearZ * farZ * fn;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix with default near/far
|
||||
* and angle values with a left-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_default_lh_zo(float aspect, mat4 dest) {
|
||||
glm_perspective_lh_zo(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief resize perspective matrix by aspect ratio ( width / height )
|
||||
* this makes very easy to resize proj matrix when window /viewport
|
||||
* reized
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in, out] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_resize_lh_zo(float aspect, mat4 proj) {
|
||||
if (proj[0][0] == 0.0f)
|
||||
return;
|
||||
|
||||
proj[0][0] = proj[1][1] / aspect;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes frustum values of perspective projection
|
||||
* with angle values with a left-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
* @param[out] farZ far
|
||||
* @param[out] top top
|
||||
* @param[out] bottom bottom
|
||||
* @param[out] left left
|
||||
* @param[out] right right
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_lh_zo(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right) {
|
||||
float m00, m11, m20, m21, m22, m32, n, f;
|
||||
float n_m11, n_m00;
|
||||
|
||||
m00 = proj[0][0];
|
||||
m11 = proj[1][1];
|
||||
m20 = proj[2][0];
|
||||
m21 = proj[2][1];
|
||||
m22 =-proj[2][2];
|
||||
m32 = proj[3][2];
|
||||
|
||||
n = m32 / m22;
|
||||
f = m32 / (m22 + 1.0f);
|
||||
|
||||
n_m11 = n / m11;
|
||||
n_m00 = n / m00;
|
||||
|
||||
*nearZ = n;
|
||||
*farZ = f;
|
||||
*bottom = n_m11 * (m21 - 1.0f);
|
||||
*top = n_m11 * (m21 + 1.0f);
|
||||
*left = n_m00 * (m20 - 1.0f);
|
||||
*right = n_m00 * (m20 + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes frustum values of perspective projection
|
||||
* with angle values with a left-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
* this makes easy to get all values at once
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] dest array
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decompv_lh_zo(mat4 proj, float dest[6]) {
|
||||
glm_persp_decomp_lh_zo(proj, &dest[0], &dest[1], &dest[2],
|
||||
&dest[3], &dest[4], &dest[5]);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes left and right values of perspective projection (ZO).
|
||||
* x stands for x axis (left / right axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] left left
|
||||
* @param[out] right right
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_x_lh_zo(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right) {
|
||||
float nearZ, m20, m00;
|
||||
|
||||
m00 = proj[0][0];
|
||||
m20 = proj[2][0];
|
||||
|
||||
nearZ = proj[3][2] / (proj[3][3]);
|
||||
*left = nearZ * (m20 - 1.0f) / m00;
|
||||
*right = nearZ * (m20 + 1.0f) / m00;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes top and bottom values of perspective projection
|
||||
* with angle values with a left-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
* y stands for y axis (top / bottom axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] top top
|
||||
* @param[out] bottom bottom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_y_lh_zo(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom) {
|
||||
float nearZ, m21, m11;
|
||||
|
||||
m21 = proj[2][1];
|
||||
m11 = proj[1][1];
|
||||
|
||||
nearZ = proj[3][2] / (proj[3][3]);
|
||||
*bottom = nearZ * (m21 - 1) / m11;
|
||||
*top = nearZ * (m21 + 1) / m11;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes near and far values of perspective projection
|
||||
* with angle values with a left-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
* z stands for z axis (near / far axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
* @param[out] farZ far
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_z_lh_zo(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ) {
|
||||
float m32, m22;
|
||||
|
||||
m32 = proj[3][2];
|
||||
m22 = -proj[2][2];
|
||||
|
||||
*nearZ = m32 / m22;
|
||||
*farZ = m32 / (m22 + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes far value of perspective projection
|
||||
* with angle values with a left-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] farZ far
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_far_lh_zo(mat4 proj, float * __restrict farZ) {
|
||||
*farZ = proj[3][2] / (-proj[2][2] + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes near value of perspective projection
|
||||
* with angle values with a left-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_near_lh_zo(mat4 proj, float * __restrict nearZ) {
|
||||
*nearZ = proj[3][2] / -proj[2][2];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns sizes of near and far planes of perspective projection
|
||||
* with a left-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[in] fovy fovy (see brief)
|
||||
* @param[out] dest sizes order: [Wnear, Hnear, Wfar, Hfar]
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_sizes_lh_zo(mat4 proj, float fovy, vec4 dest) {
|
||||
float t, a, nearZ, farZ;
|
||||
|
||||
t = 2.0f * tanf(fovy * 0.5f);
|
||||
a = glm_persp_aspect(proj);
|
||||
|
||||
glm_persp_decomp_z_lh_zo(proj, &nearZ, &farZ);
|
||||
|
||||
dest[1] = t * nearZ;
|
||||
dest[3] = t * farZ;
|
||||
dest[0] = a * dest[1];
|
||||
dest[2] = a * dest[3];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns field of view angle along the Y-axis (in radians)
|
||||
* with a left-hand coordinate system and a clip-space of [0, 1].
|
||||
*
|
||||
* if you need to degrees, use glm_deg to convert it or use this:
|
||||
* fovy_deg = glm_deg(glm_persp_fovy(projMatrix))
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_fovy_lh_zo(mat4 proj) {
|
||||
return glm_persp_fovy(proj);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns aspect ratio of perspective projection
|
||||
* with a left-hand coordinate system and a clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_aspect_lh_zo(mat4 proj) {
|
||||
return glm_persp_aspect(proj);
|
||||
}
|
||||
|
||||
#endif /*cglm_persp_lh_zo_h*/
|
396
include/cglm/clipspace/persp_rh_no.h
Normal file
396
include/cglm/clipspace/persp_rh_no.h
Normal file
@@ -0,0 +1,396 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_frustum_rh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_rh_no(float fovy,
|
||||
float aspect,
|
||||
float nearZ,
|
||||
float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_default_rh_no(float aspect, mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_resize_rh_no(float aspect, mat4 proj)
|
||||
CGLM_INLINE void glm_persp_move_far_rh_no(mat4 proj,
|
||||
float deltaFar)
|
||||
CGLM_INLINE void glm_persp_decomp_rh_no(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom,
|
||||
float * __restrict left,
|
||||
float * __restrict right)
|
||||
CGLM_INLINE void glm_persp_decompv_rh_no(mat4 proj,
|
||||
float dest[6])
|
||||
CGLM_INLINE void glm_persp_decomp_x_rh_no(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right)
|
||||
CGLM_INLINE void glm_persp_decomp_y_rh_no(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom)
|
||||
CGLM_INLINE void glm_persp_decomp_z_rh_no(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ)
|
||||
CGLM_INLINE void glm_persp_decomp_far_rh_no(mat4 proj, float * __restrict farZ)
|
||||
CGLM_INLINE void glm_persp_decomp_near_rh_no(mat4 proj, float * __restrict nearZ)
|
||||
CGLM_INLINE void glm_persp_sizes_rh_no(mat4 proj, float fovy, vec4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_persp_rh_no_h
|
||||
#define cglm_persp_rh_no_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
#include "persp.h"
|
||||
|
||||
/*!
|
||||
* @brief set up perspective peprojection matrix
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] left viewport.left
|
||||
* @param[in] right viewport.right
|
||||
* @param[in] bottom viewport.bottom
|
||||
* @param[in] top viewport.top
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping plane
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_frustum_rh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
float rl, tb, fn, nv;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
rl = 1.0f / (right - left);
|
||||
tb = 1.0f / (top - bottom);
|
||||
fn =-1.0f / (farZ - nearZ);
|
||||
nv = 2.0f * nearZ;
|
||||
|
||||
dest[0][0] = nv * rl;
|
||||
dest[1][1] = nv * tb;
|
||||
dest[2][0] = (right + left) * rl;
|
||||
dest[2][1] = (top + bottom) * tb;
|
||||
dest[2][2] = (farZ + nearZ) * fn;
|
||||
dest[2][3] =-1.0f;
|
||||
dest[3][2] = farZ * nv * fn;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] fovy field of view angle
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping planes
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_rh_no(float fovy,
|
||||
float aspect,
|
||||
float nearZ,
|
||||
float farZ,
|
||||
mat4 dest) {
|
||||
float f, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
f = 1.0f / tanf(fovy * 0.5f);
|
||||
fn = 1.0f / (nearZ - farZ);
|
||||
|
||||
dest[0][0] = f / aspect;
|
||||
dest[1][1] = f;
|
||||
dest[2][2] = (nearZ + farZ) * fn;
|
||||
dest[2][3] =-1.0f;
|
||||
dest[3][2] = 2.0f * nearZ * farZ * fn;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix with default near/far
|
||||
* and angle values with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_default_rh_no(float aspect, mat4 dest) {
|
||||
glm_perspective_rh_no(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief resize perspective matrix by aspect ratio ( width / height )
|
||||
* this makes very easy to resize proj matrix when window /viewport
|
||||
* resized with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in, out] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_resize_rh_no(float aspect, mat4 proj) {
|
||||
if (proj[0][0] == 0.0f)
|
||||
return;
|
||||
|
||||
proj[0][0] = proj[1][1] / aspect;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief extend perspective projection matrix's far distance
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* this function does not guarantee far >= near, be aware of that!
|
||||
*
|
||||
* @param[in, out] proj projection matrix to extend
|
||||
* @param[in] deltaFar distance from existing far (negative to shink)
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_move_far_rh_no(mat4 proj, float deltaFar) {
|
||||
float fn, farZ, nearZ, p22, p32;
|
||||
|
||||
p22 = proj[2][2];
|
||||
p32 = proj[3][2];
|
||||
|
||||
nearZ = p32 / (p22 - 1.0f);
|
||||
farZ = p32 / (p22 + 1.0f) + deltaFar;
|
||||
fn = 1.0f / (nearZ - farZ);
|
||||
|
||||
proj[2][2] = (farZ + nearZ) * fn;
|
||||
proj[3][2] = 2.0f * nearZ * farZ * fn;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes frustum values of perspective projection
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
* @param[out] farZ far
|
||||
* @param[out] top top
|
||||
* @param[out] bottom bottom
|
||||
* @param[out] left left
|
||||
* @param[out] right right
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_rh_no(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right) {
|
||||
float m00, m11, m20, m21, m22, m32, n, f;
|
||||
float n_m11, n_m00;
|
||||
|
||||
m00 = proj[0][0];
|
||||
m11 = proj[1][1];
|
||||
m20 = proj[2][0];
|
||||
m21 = proj[2][1];
|
||||
m22 = proj[2][2];
|
||||
m32 = proj[3][2];
|
||||
|
||||
n = m32 / (m22 - 1.0f);
|
||||
f = m32 / (m22 + 1.0f);
|
||||
|
||||
n_m11 = n / m11;
|
||||
n_m00 = n / m00;
|
||||
|
||||
*nearZ = n;
|
||||
*farZ = f;
|
||||
*bottom = n_m11 * (m21 - 1.0f);
|
||||
*top = n_m11 * (m21 + 1.0f);
|
||||
*left = n_m00 * (m20 - 1.0f);
|
||||
*right = n_m00 * (m20 + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes frustum values of perspective projection
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
* this makes easy to get all values at once
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] dest array
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decompv_rh_no(mat4 proj, float dest[6]) {
|
||||
glm_persp_decomp_rh_no(proj, &dest[0], &dest[1], &dest[2],
|
||||
&dest[3], &dest[4], &dest[5]);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes left and right values of perspective projection
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
* x stands for x axis (left / right axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] left left
|
||||
* @param[out] right right
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_x_rh_no(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right) {
|
||||
float nearZ, m20, m00, m22;
|
||||
|
||||
m00 = proj[0][0];
|
||||
m20 = proj[2][0];
|
||||
m22 = proj[2][2];
|
||||
|
||||
nearZ = proj[3][2] / (m22 - 1.0f);
|
||||
*left = nearZ * (m20 - 1.0f) / m00;
|
||||
*right = nearZ * (m20 + 1.0f) / m00;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes top and bottom values of perspective projection
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
* y stands for y axis (top / botom axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] top top
|
||||
* @param[out] bottom bottom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_y_rh_no(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom) {
|
||||
float nearZ, m21, m11, m22;
|
||||
|
||||
m21 = proj[2][1];
|
||||
m11 = proj[1][1];
|
||||
m22 = proj[2][2];
|
||||
|
||||
nearZ = proj[3][2] / (m22 - 1.0f);
|
||||
*bottom = nearZ * (m21 - 1.0f) / m11;
|
||||
*top = nearZ * (m21 + 1.0f) / m11;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes near and far values of perspective projection
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
* z stands for z axis (near / far axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
* @param[out] farZ far
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_z_rh_no(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ) {
|
||||
float m32, m22;
|
||||
|
||||
m32 = proj[3][2];
|
||||
m22 = proj[2][2];
|
||||
|
||||
*nearZ = m32 / (m22 - 1.0f);
|
||||
*farZ = m32 / (m22 + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes far value of perspective projection
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] farZ far
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_far_rh_no(mat4 proj, float * __restrict farZ) {
|
||||
*farZ = proj[3][2] / (proj[2][2] + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes near value of perspective projection
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_near_rh_no(mat4 proj, float * __restrict nearZ) {
|
||||
*nearZ = proj[3][2] / (proj[2][2] - 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns sizes of near and far planes of perspective projection
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[in] fovy fovy (see brief)
|
||||
* @param[out] dest sizes order: [Wnear, Hnear, Wfar, Hfar]
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_sizes_rh_no(mat4 proj, float fovy, vec4 dest) {
|
||||
float t, a, nearZ, farZ;
|
||||
|
||||
t = 2.0f * tanf(fovy * 0.5f);
|
||||
a = glm_persp_aspect(proj);
|
||||
|
||||
glm_persp_decomp_z_rh_no(proj, &nearZ, &farZ);
|
||||
|
||||
dest[1] = t * nearZ;
|
||||
dest[3] = t * farZ;
|
||||
dest[0] = a * dest[1];
|
||||
dest[2] = a * dest[3];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns field of view angle along the Y-axis (in radians)
|
||||
* with a right-hand coordinate system and a clip-space of [-1, 1].
|
||||
*
|
||||
* if you need to degrees, use glm_deg to convert it or use this:
|
||||
* fovy_deg = glm_deg(glm_persp_fovy(projMatrix))
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_fovy_rh_no(mat4 proj) {
|
||||
return glm_persp_fovy(proj);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns aspect ratio of perspective projection
|
||||
* with a right-hand coordinate system and a clip-space of [-1, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_aspect_rh_no(mat4 proj) {
|
||||
return glm_persp_aspect(proj);
|
||||
}
|
||||
|
||||
#endif /*cglm_cam_rh_no_h*/
|
390
include/cglm/clipspace/persp_rh_zo.h
Normal file
390
include/cglm/clipspace/persp_rh_zo.h
Normal file
@@ -0,0 +1,390 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_frustum_rh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_rh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearZ,
|
||||
float farZ,
|
||||
mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_default_rh_zo(float aspect, mat4 dest)
|
||||
CGLM_INLINE void glm_perspective_resize_rh_zo(float aspect, mat4 proj)
|
||||
CGLM_INLINE void glm_persp_move_far_rh_zo(mat4 proj,
|
||||
float deltaFar)
|
||||
CGLM_INLINE void glm_persp_decomp_rh_zo(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom,
|
||||
float * __restrict left,
|
||||
float * __restrict right)
|
||||
CGLM_INLINE void glm_persp_decompv_rh_zo(mat4 proj,
|
||||
float dest[6])
|
||||
CGLM_INLINE void glm_persp_decomp_x_rh_zo(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right)
|
||||
CGLM_INLINE void glm_persp_decomp_y_rh_zo(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom)
|
||||
CGLM_INLINE void glm_persp_decomp_z_rh_zo(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ)
|
||||
CGLM_INLINE void glm_persp_decomp_far_rh_zo(mat4 proj, float * __restrict farZ)
|
||||
CGLM_INLINE void glm_persp_decomp_near_rh_zo(mat4 proj, float * __restrict nearZ)
|
||||
CGLM_INLINE void glm_persp_sizes_rh_zo(mat4 proj, float fovy, vec4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_persp_rh_zo_h
|
||||
#define cglm_persp_rh_zo_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
#include "persp.h"
|
||||
|
||||
/*!
|
||||
* @brief set up perspective peprojection matrix with a right-hand coordinate
|
||||
* system and a clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] left viewport.left
|
||||
* @param[in] right viewport.right
|
||||
* @param[in] bottom viewport.bottom
|
||||
* @param[in] top viewport.top
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping plane
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_frustum_rh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
float rl, tb, fn, nv;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
rl = 1.0f / (right - left);
|
||||
tb = 1.0f / (top - bottom);
|
||||
fn =-1.0f / (farZ - nearZ);
|
||||
nv = 2.0f * nearZ;
|
||||
|
||||
dest[0][0] = nv * rl;
|
||||
dest[1][1] = nv * tb;
|
||||
dest[2][0] = (right + left) * rl;
|
||||
dest[2][1] = (top + bottom) * tb;
|
||||
dest[2][2] = farZ * fn;
|
||||
dest[2][3] =-1.0f;
|
||||
dest[3][2] = farZ * nearZ * fn;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix with a right-hand coordinate
|
||||
* system and a clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] fovy field of view angle
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in] nearZ near clipping plane
|
||||
* @param[in] farZ far clipping planes
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_rh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearZ,
|
||||
float farZ,
|
||||
mat4 dest) {
|
||||
float f, fn;
|
||||
|
||||
glm_mat4_zero(dest);
|
||||
|
||||
f = 1.0f / tanf(fovy * 0.5f);
|
||||
fn = 1.0f / (nearZ - farZ);
|
||||
|
||||
dest[0][0] = f / aspect;
|
||||
dest[1][1] = f;
|
||||
dest[2][2] = farZ * fn;
|
||||
dest[2][3] =-1.0f;
|
||||
dest[3][2] = nearZ * farZ * fn;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up perspective projection matrix with default near/far
|
||||
* and angle values with a right-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_default_rh_zo(float aspect, mat4 dest) {
|
||||
glm_perspective_rh_zo(GLM_PI_4f, aspect, 0.01f, 100.0f, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief resize perspective matrix by aspect ratio ( width / height )
|
||||
* this makes very easy to resize proj matrix when window /viewport
|
||||
* resized with a right-hand coordinate system and a clip-space of
|
||||
* [0, 1].
|
||||
*
|
||||
* @param[in] aspect aspect ratio ( width / height )
|
||||
* @param[in, out] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_perspective_resize_rh_zo(float aspect, mat4 proj) {
|
||||
if (proj[0][0] == 0.0f)
|
||||
return;
|
||||
|
||||
proj[0][0] = proj[1][1] / aspect;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief extend perspective projection matrix's far distance with a
|
||||
* right-hand coordinate system and a clip-space of [0, 1].
|
||||
*
|
||||
* this function does not guarantee far >= near, be aware of that!
|
||||
*
|
||||
* @param[in, out] proj projection matrix to extend
|
||||
* @param[in] deltaFar distance from existing far (negative to shink)
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_move_far_rh_zo(mat4 proj, float deltaFar) {
|
||||
float fn, farZ, nearZ, p22, p32;
|
||||
|
||||
p22 = proj[2][2];
|
||||
p32 = proj[3][2];
|
||||
|
||||
nearZ = p32 / p22;
|
||||
farZ = p32 / (p22 + 1.0f) + deltaFar;
|
||||
fn = 1.0f / (nearZ - farZ);
|
||||
|
||||
proj[2][2] = farZ * fn;
|
||||
proj[3][2] = nearZ * farZ * fn;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes frustum values of perspective projection
|
||||
* with angle values with a right-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
* @param[out] farZ far
|
||||
* @param[out] top top
|
||||
* @param[out] bottom bottom
|
||||
* @param[out] left left
|
||||
* @param[out] right right
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_rh_zo(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right) {
|
||||
float m00, m11, m20, m21, m22, m32, n, f;
|
||||
float n_m11, n_m00;
|
||||
|
||||
m00 = proj[0][0];
|
||||
m11 = proj[1][1];
|
||||
m20 = proj[2][0];
|
||||
m21 = proj[2][1];
|
||||
m22 = proj[2][2];
|
||||
m32 = proj[3][2];
|
||||
|
||||
n = m32 / m22;
|
||||
f = m32 / (m22 + 1.0f);
|
||||
|
||||
n_m11 = n / m11;
|
||||
n_m00 = n / m00;
|
||||
|
||||
*nearZ = n;
|
||||
*farZ = f;
|
||||
*bottom = n_m11 * (m21 - 1.0f);
|
||||
*top = n_m11 * (m21 + 1.0f);
|
||||
*left = n_m00 * (m20 - 1.0f);
|
||||
*right = n_m00 * (m20 + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes frustum values of perspective projection
|
||||
* with angle values with a right-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
* this makes easy to get all values at once
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] dest array
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decompv_rh_zo(mat4 proj, float dest[6]) {
|
||||
glm_persp_decomp_rh_zo(proj, &dest[0], &dest[1], &dest[2],
|
||||
&dest[3], &dest[4], &dest[5]);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes left and right values of perspective projection (ZO).
|
||||
* x stands for x axis (left / right axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] left left
|
||||
* @param[out] right right
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_x_rh_zo(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right) {
|
||||
float nearZ, m20, m00, m22;
|
||||
|
||||
m00 = proj[0][0];
|
||||
m20 = proj[2][0];
|
||||
m22 = proj[2][2];
|
||||
|
||||
nearZ = proj[3][2] / m22;
|
||||
*left = nearZ * (m20 - 1.0f) / m00;
|
||||
*right = nearZ * (m20 + 1.0f) / m00;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes top and bottom values of perspective projection
|
||||
* with angle values with a right-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
* y stands for y axis (top / bottom axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] top top
|
||||
* @param[out] bottom bottom
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_y_rh_zo(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom) {
|
||||
float nearZ, m21, m11, m22;
|
||||
|
||||
m21 = proj[2][1];
|
||||
m11 = proj[1][1];
|
||||
m22 = proj[2][2];
|
||||
|
||||
nearZ = proj[3][2] / m22;
|
||||
*bottom = nearZ * (m21 - 1) / m11;
|
||||
*top = nearZ * (m21 + 1) / m11;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes near and far values of perspective projection
|
||||
* with angle values with a right-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
* z stands for z axis (near / far axis)
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
* @param[out] farZ far
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_z_rh_zo(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ) {
|
||||
float m32, m22;
|
||||
|
||||
m32 = proj[3][2];
|
||||
m22 = proj[2][2];
|
||||
|
||||
*nearZ = m32 / m22;
|
||||
*farZ = m32 / (m22 + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes far value of perspective projection
|
||||
* with angle values with a right-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] farZ far
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_far_rh_zo(mat4 proj, float * __restrict farZ) {
|
||||
*farZ = proj[3][2] / (proj[2][2] + 1.0f);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief decomposes near value of perspective projection
|
||||
* with angle values with a right-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[out] nearZ near
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_decomp_near_rh_zo(mat4 proj, float * __restrict nearZ) {
|
||||
*nearZ = proj[3][2] / proj[2][2];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns sizes of near and far planes of perspective projection
|
||||
* with a right-hand coordinate system and a
|
||||
* clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
* @param[in] fovy fovy (see brief)
|
||||
* @param[out] dest sizes order: [Wnear, Hnear, Wfar, Hfar]
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_persp_sizes_rh_zo(mat4 proj, float fovy, vec4 dest) {
|
||||
float t, a, nearZ, farZ;
|
||||
|
||||
t = 2.0f * tanf(fovy * 0.5f);
|
||||
a = glm_persp_aspect(proj);
|
||||
|
||||
glm_persp_decomp_z_rh_zo(proj, &nearZ, &farZ);
|
||||
|
||||
dest[1] = t * nearZ;
|
||||
dest[3] = t * farZ;
|
||||
dest[0] = a * dest[1];
|
||||
dest[2] = a * dest[3];
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns field of view angle along the Y-axis (in radians)
|
||||
* with a right-hand coordinate system and a clip-space of [0, 1].
|
||||
*
|
||||
* if you need to degrees, use glm_deg to convert it or use this:
|
||||
* fovy_deg = glm_deg(glm_persp_fovy(projMatrix))
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_fovy_rh_zo(mat4 proj) {
|
||||
return glm_persp_fovy(proj);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief returns aspect ratio of perspective projection
|
||||
* with a right-hand coordinate system and a clip-space of [0, 1].
|
||||
*
|
||||
* @param[in] proj perspective projection matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
float
|
||||
glm_persp_aspect_rh_zo(mat4 proj) {
|
||||
return glm_persp_aspect(proj);
|
||||
}
|
||||
|
||||
#endif /*cglm_persp_rh_zo_h*/
|
99
include/cglm/clipspace/view_lh.h
Normal file
99
include/cglm/clipspace/view_lh.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_lookat_lh(vec3 eye, vec3 center, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_lh(vec3 eye, vec3 dir, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_anyup_lh(vec3 eye, vec3 dir, mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_view_lh_h
|
||||
#define cglm_view_lh_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix (LH)
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] center center vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_lookat_lh(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
CGLM_ALIGN(8) vec3 f, u, s;
|
||||
|
||||
glm_vec3_sub(center, eye, f);
|
||||
glm_vec3_normalize(f);
|
||||
|
||||
glm_vec3_crossn(f, up, s);
|
||||
glm_vec3_cross(s, f, u);
|
||||
|
||||
dest[0][0] = s[0];
|
||||
dest[0][1] = u[0];
|
||||
dest[0][2] = f[0];
|
||||
dest[1][0] = s[1];
|
||||
dest[1][1] = u[1];
|
||||
dest[1][2] = f[1];
|
||||
dest[2][0] = s[2];
|
||||
dest[2][1] = u[2];
|
||||
dest[2][2] = f[2];
|
||||
dest[3][0] =-glm_vec3_dot(s, eye);
|
||||
dest[3][1] =-glm_vec3_dot(u, eye);
|
||||
dest[3][2] =-glm_vec3_dot(f, eye);
|
||||
dest[0][3] = dest[1][3] = dest[2][3] = 0.0f;
|
||||
dest[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with left handed coordinate system
|
||||
*
|
||||
* convenient wrapper for lookat: if you only have direction not target self
|
||||
* then this might be useful. Because you need to get target from direction.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_lh(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
CGLM_ALIGN(8) vec3 target;
|
||||
glm_vec3_add(eye, dir, target);
|
||||
glm_lookat_lh(eye, target, up, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with left handed coordinate system
|
||||
*
|
||||
* convenient wrapper for look: if you only have direction and if you don't
|
||||
* care what UP vector is then this might be useful to create view matrix
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_anyup_lh(vec3 eye, vec3 dir, mat4 dest) {
|
||||
CGLM_ALIGN(8) vec3 up;
|
||||
glm_vec3_ortho(dir, up);
|
||||
glm_look_lh(eye, dir, up, dest);
|
||||
}
|
||||
|
||||
#endif /*cglm_view_lh_h*/
|
73
include/cglm/clipspace/view_lh_no.h
Normal file
73
include/cglm/clipspace/view_lh_no.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_lookat_lh_no(vec3 eye, vec3 center, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_lh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_anyup_lh_no(vec3 eye, vec3 dir, mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_view_lh_no_h
|
||||
#define cglm_view_lh_no_h
|
||||
|
||||
#include "view_lh.h"
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with left handed coordinate system.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] center center vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_lookat_lh_no(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
glm_lookat_lh(eye, center, up, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with left handed coordinate system.
|
||||
*
|
||||
* convenient wrapper for lookat: if you only have direction not target self
|
||||
* then this might be useful. Because you need to get target from direction.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_lh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
glm_look_lh(eye, dir, up, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with left handed coordinate system.
|
||||
*
|
||||
* convenient wrapper for look: if you only have direction and if you don't
|
||||
* care what UP vector is then this might be useful to create view matrix
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_anyup_lh_no(vec3 eye, vec3 dir, mat4 dest) {
|
||||
glm_look_anyup_lh(eye, dir, dest);
|
||||
}
|
||||
|
||||
#endif /*cglm_view_lh_no_h*/
|
73
include/cglm/clipspace/view_lh_zo.h
Normal file
73
include/cglm/clipspace/view_lh_zo.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_lookat_lh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_lh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_anyup_lh_zo(vec3 eye, vec3 dir, mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_view_lh_zo_h
|
||||
#define cglm_view_lh_zo_h
|
||||
|
||||
#include "view_lh.h"
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with left handed coordinate system.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] center center vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_lookat_lh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
glm_lookat_lh(eye, center, up, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with left handed coordinate system.
|
||||
*
|
||||
* convenient wrapper for lookat: if you only have direction not target self
|
||||
* then this might be useful. Because you need to get target from direction.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_lh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
glm_look_lh(eye, dir, up, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with left handed coordinate system.
|
||||
*
|
||||
* convenient wrapper for look: if you only have direction and if you don't
|
||||
* care what UP vector is then this might be useful to create view matrix
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_anyup_lh_zo(vec3 eye, vec3 dir, mat4 dest) {
|
||||
glm_look_anyup_lh(eye, dir, dest);
|
||||
}
|
||||
|
||||
#endif /*cglm_view_lh_zo_h*/
|
99
include/cglm/clipspace/view_rh.h
Normal file
99
include/cglm/clipspace/view_rh.h
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_lookat_rh(vec3 eye, vec3 center, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_rh(vec3 eye, vec3 dir, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_anyup_rh(vec3 eye, vec3 dir, mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_view_rh_h
|
||||
#define cglm_view_rh_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../plane.h"
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with right handed coordinate system.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] center center vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_lookat_rh(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
CGLM_ALIGN(8) vec3 f, u, s;
|
||||
|
||||
glm_vec3_sub(center, eye, f);
|
||||
glm_vec3_normalize(f);
|
||||
|
||||
glm_vec3_crossn(f, up, s);
|
||||
glm_vec3_cross(s, f, u);
|
||||
|
||||
dest[0][0] = s[0];
|
||||
dest[0][1] = u[0];
|
||||
dest[0][2] =-f[0];
|
||||
dest[1][0] = s[1];
|
||||
dest[1][1] = u[1];
|
||||
dest[1][2] =-f[1];
|
||||
dest[2][0] = s[2];
|
||||
dest[2][1] = u[2];
|
||||
dest[2][2] =-f[2];
|
||||
dest[3][0] =-glm_vec3_dot(s, eye);
|
||||
dest[3][1] =-glm_vec3_dot(u, eye);
|
||||
dest[3][2] = glm_vec3_dot(f, eye);
|
||||
dest[0][3] = dest[1][3] = dest[2][3] = 0.0f;
|
||||
dest[3][3] = 1.0f;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with right handed coordinate system.
|
||||
*
|
||||
* convenient wrapper for lookat: if you only have direction not target self
|
||||
* then this might be useful. Because you need to get target from direction.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_rh(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
CGLM_ALIGN(8) vec3 target;
|
||||
glm_vec3_add(eye, dir, target);
|
||||
glm_lookat_rh(eye, target, up, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with right handed coordinate system.
|
||||
*
|
||||
* convenient wrapper for look: if you only have direction and if you don't
|
||||
* care what UP vector is then this might be useful to create view matrix
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_anyup_rh(vec3 eye, vec3 dir, mat4 dest) {
|
||||
CGLM_ALIGN(8) vec3 up;
|
||||
glm_vec3_ortho(dir, up);
|
||||
glm_look_rh(eye, dir, up, dest);
|
||||
}
|
||||
|
||||
#endif /*cglm_view_rh_h*/
|
73
include/cglm/clipspace/view_rh_no.h
Normal file
73
include/cglm/clipspace/view_rh_no.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_lookat_rh_no(vec3 eye, vec3 center, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_rh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_anyup_rh_no(vec3 eye, vec3 dir, mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_view_rh_no_h
|
||||
#define cglm_view_rh_no_h
|
||||
|
||||
#include "view_rh.h"
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with right handed coordinate system.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] center center vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_lookat_rh_no(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
glm_lookat_rh(eye, center, up, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with right handed coordinate system.
|
||||
*
|
||||
* convenient wrapper for lookat: if you only have direction not target self
|
||||
* then this might be useful. Because you need to get target from direction.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_rh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
glm_look_rh(eye, dir, up, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with right handed coordinate system.
|
||||
*
|
||||
* convenient wrapper for look: if you only have direction and if you don't
|
||||
* care what UP vector is then this might be useful to create view matrix
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_anyup_rh_no(vec3 eye, vec3 dir, mat4 dest) {
|
||||
glm_look_anyup_rh(eye, dir, dest);
|
||||
}
|
||||
|
||||
#endif /*cglm_view_rh_no_h*/
|
73
include/cglm/clipspace/view_rh_zo.h
Normal file
73
include/cglm/clipspace/view_rh_zo.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions:
|
||||
CGLM_INLINE void glm_lookat_rh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_rh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest)
|
||||
CGLM_INLINE void glm_look_anyup_rh_zo(vec3 eye, vec3 dir, mat4 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_view_rh_zo_h
|
||||
#define cglm_view_rh_zo_h
|
||||
|
||||
#include "view_rh.h"
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with right handed coordinate system.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] center center vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_lookat_rh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
glm_lookat_rh(eye, center, up, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with right handed coordinate system.
|
||||
*
|
||||
* convenient wrapper for lookat: if you only have direction not target self
|
||||
* then this might be useful. Because you need to get target from direction.
|
||||
*
|
||||
* NOTE: The UP vector must not be parallel to the line of sight from
|
||||
* the eye point to the reference point
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[in] up up vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_rh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
glm_look_rh(eye, dir, up, dest);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief set up view matrix with right handed coordinate system.
|
||||
*
|
||||
* convenient wrapper for look: if you only have direction and if you don't
|
||||
* care what UP vector is then this might be useful to create view matrix
|
||||
*
|
||||
* @param[in] eye eye vector
|
||||
* @param[in] dir direction vector
|
||||
* @param[out] dest result matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_look_anyup_rh_zo(vec3 eye, vec3 dir, mat4 dest) {
|
||||
glm_look_anyup_rh(eye, dir, dest);
|
||||
}
|
||||
|
||||
#endif /*cglm_view_rh_zo_h*/
|
@@ -50,4 +50,35 @@
|
||||
# define GLM_FLT_EPSILON FLT_EPSILON
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Clip control: define GLM_FORCE_DEPTH_ZERO_TO_ONE before including
|
||||
* CGLM to use a clip space between 0 to 1.
|
||||
* Coordinate system: define GLM_FORCE_LEFT_HANDED before including
|
||||
* CGLM to use the left handed coordinate system by default.
|
||||
*/
|
||||
|
||||
#define CGLM_CLIP_CONTROL_ZO_BIT (1 << 0) /* ZERO_TO_ONE */
|
||||
#define CGLM_CLIP_CONTROL_NO_BIT (1 << 1) /* NEGATIVE_ONE_TO_ONE */
|
||||
#define CGLM_CLIP_CONTROL_LH_BIT (1 << 2) /* LEFT_HANDED, For DirectX, Metal, Vulkan */
|
||||
#define CGLM_CLIP_CONTROL_RH_BIT (1 << 3) /* RIGHT_HANDED, For OpenGL, default in GLM */
|
||||
|
||||
#define CGLM_CLIP_CONTROL_LH_ZO (CGLM_CLIP_CONTROL_LH_BIT | CGLM_CLIP_CONTROL_ZO_BIT)
|
||||
#define CGLM_CLIP_CONTROL_LH_NO (CGLM_CLIP_CONTROL_LH_BIT | CGLM_CLIP_CONTROL_NO_BIT)
|
||||
#define CGLM_CLIP_CONTROL_RH_ZO (CGLM_CLIP_CONTROL_RH_BIT | CGLM_CLIP_CONTROL_ZO_BIT)
|
||||
#define CGLM_CLIP_CONTROL_RH_NO (CGLM_CLIP_CONTROL_RH_BIT | CGLM_CLIP_CONTROL_NO_BIT)
|
||||
|
||||
#ifdef CGLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||
# ifdef CGLM_FORCE_LEFT_HANDED
|
||||
# define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_LH_ZO
|
||||
# else
|
||||
# define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_RH_ZO
|
||||
# endif
|
||||
#else
|
||||
# ifdef CGLM_FORCE_LEFT_HANDED
|
||||
# define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_LH_NO
|
||||
# else
|
||||
# define CGLM_CONFIG_CLIP_CONTROL CGLM_CLIP_CONTROL_RH_NO
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* cglm_common_h */
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#define cglm_plane_h
|
||||
|
||||
#include "common.h"
|
||||
#include "vec3.h"
|
||||
#include "vec4.h"
|
||||
|
||||
/*
|
||||
|
14
meson.build
14
meson.build
@@ -48,7 +48,19 @@ cglm_src = files(
|
||||
'src/sphere.c',
|
||||
'src/vec2.c',
|
||||
'src/vec3.c',
|
||||
'src/vec4.c'
|
||||
'src/vec4.c',
|
||||
'src/clipspace/ortho_lh_no.c',
|
||||
'src/clipspace/ortho_lh_zo.c',
|
||||
'src/clipspace/ortho_rh_no.c',
|
||||
'src/clipspace/ortho_rh_zo.c',
|
||||
'src/clipspace/persp_lh_no.c',
|
||||
'src/clipspace/persp_lh_zo.c',
|
||||
'src/clipspace/persp_rh_no.c',
|
||||
'src/clipspace/persp_rh_zo.c'
|
||||
'src/clipspace/view_lh_no.c',
|
||||
'src/clipspace/view_lh_zo.c',
|
||||
'src/clipspace/view_rh_no.c'
|
||||
'src/clipspace/view_rh_zo.c'
|
||||
)
|
||||
|
||||
cglm_lib = library('cglm',
|
||||
|
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_lh_no(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
glm_perspective_lh_no(fovy,
|
||||
aspect,
|
||||
nearVal,
|
||||
farVal,
|
||||
dest);
|
||||
}
|
||||
|
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_lh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
glm_perspective_lh_zo(fovy,
|
||||
aspect,
|
||||
nearVal,
|
||||
farVal,
|
||||
dest);
|
||||
}
|
||||
|
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_rh_no(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
glm_perspective_rh_no(fovy,
|
||||
aspect,
|
||||
nearVal,
|
||||
farVal,
|
||||
dest);
|
||||
}
|
||||
|
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_rh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
glm_perspective_rh_zo(fovy,
|
||||
aspect,
|
||||
nearVal,
|
||||
farVal,
|
||||
dest);
|
||||
}
|
||||
|
51
src/clipspace/ortho_lh_no.c
Normal file
51
src/clipspace/ortho_lh_no.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
#include "../include/cglm/clipspace/ortho_lh_no.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_lh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
glm_ortho_lh_no(left, right,
|
||||
bottom, top,
|
||||
nearZ, farZ,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_lh_no(vec3 box[2], mat4 dest) {
|
||||
glm_ortho_aabb_lh_no(box, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_p_lh_no(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_aabb_p_lh_no(box, padding, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_pz_lh_no(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_aabb_pz_lh_no(box, padding, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_lh_no(float aspect, mat4 dest) {
|
||||
glm_ortho_default_lh_no(aspect, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_s_lh_no(float aspect, float size, mat4 dest) {
|
||||
glm_ortho_default_s_lh_no(aspect, size, dest);
|
||||
}
|
51
src/clipspace/ortho_lh_zo.c
Normal file
51
src/clipspace/ortho_lh_zo.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
#include "../include/cglm/clipspace/ortho_lh_zo.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_lh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
glm_ortho_lh_zo(left, right,
|
||||
bottom, top,
|
||||
nearZ, farZ,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_lh_zo(vec3 box[2], mat4 dest) {
|
||||
glm_ortho_aabb_lh_zo(box, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_p_lh_zo(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_aabb_p_lh_zo(box, padding, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_pz_lh_zo(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_aabb_pz_lh_zo(box, padding, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_lh_zo(float aspect, mat4 dest) {
|
||||
glm_ortho_default_lh_zo(aspect, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_s_lh_zo(float aspect, float size, mat4 dest) {
|
||||
glm_ortho_default_s_lh_zo(aspect, size, dest);
|
||||
}
|
51
src/clipspace/ortho_rh_no.c
Normal file
51
src/clipspace/ortho_rh_no.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
#include "../include/cglm/clipspace/ortho_rh_no.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_rh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
glm_ortho_rh_no(left, right,
|
||||
bottom, top,
|
||||
nearZ, farZ,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_rh_no(vec3 box[2], mat4 dest) {
|
||||
glm_ortho_aabb_rh_no(box, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_p_rh_no(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_aabb_p_rh_no(box, padding, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_pz_rh_no(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_aabb_pz_rh_no(box, padding, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_rh_no(float aspect, mat4 dest) {
|
||||
glm_ortho_default_rh_no(aspect, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_s_rh_no(float aspect, float size, mat4 dest) {
|
||||
glm_ortho_default_s_rh_no(aspect, size, dest);
|
||||
}
|
51
src/clipspace/ortho_rh_zo.c
Normal file
51
src/clipspace/ortho_rh_zo.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
#include "../include/cglm/clipspace/ortho_rh_zo.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_rh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
glm_ortho_rh_zo(left, right,
|
||||
bottom, top,
|
||||
nearZ, farZ,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_rh_zo(vec3 box[2], mat4 dest) {
|
||||
glm_ortho_aabb_rh_zo(box, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_p_rh_zo(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_aabb_p_rh_zo(box, padding, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_aabb_pz_rh_zo(vec3 box[2], float padding, mat4 dest) {
|
||||
glm_ortho_aabb_pz_rh_zo(box, padding, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_rh_zo(float aspect, mat4 dest) {
|
||||
glm_ortho_default_rh_zo(aspect, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_ortho_default_s_rh_zo(float aspect, float size, mat4 dest) {
|
||||
glm_ortho_default_s_rh_zo(aspect, size, dest);
|
||||
}
|
109
src/clipspace/persp_lh_no.c
Normal file
109
src/clipspace/persp_lh_no.c
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/clipspace/persp_lh_no.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_frustum_lh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
glm_frustum_lh_no(left, right,
|
||||
bottom, top,
|
||||
nearZ, farZ,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_lh_no(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
glm_perspective_lh_no(fovy,
|
||||
aspect,
|
||||
nearVal,
|
||||
farVal,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_move_far_lh_no(mat4 proj, float deltaFar) {
|
||||
glm_persp_move_far_lh_no(proj, deltaFar);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_lh_no(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right) {
|
||||
glm_persp_decomp_lh_no(proj, nearZ, farZ, top, bottom, left, right);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decompv_lh_no(mat4 proj, float dest[6]) {
|
||||
glm_persp_decompv_lh_no(proj, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_x_lh_no(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right) {
|
||||
glm_persp_decomp_x_lh_no(proj, left, right);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_y_lh_no(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom) {
|
||||
glm_persp_decomp_y_lh_no(proj, top, bottom);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_z_lh_no(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ) {
|
||||
glm_persp_decomp_z_lh_no(proj, nearZ, farZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_far_lh_no(mat4 proj, float * __restrict farZ) {
|
||||
glm_persp_decomp_far_lh_no(proj, farZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_near_lh_no(mat4 proj, float * __restrict nearZ) {
|
||||
glm_persp_decomp_near_lh_no(proj, nearZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_sizes_lh_no(mat4 proj, float fovy, vec4 dest) {
|
||||
glm_persp_sizes_lh_no(proj, fovy, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_fovy_lh_no(mat4 proj) {
|
||||
return glm_persp_fovy_lh_no(proj);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_aspect_lh_no(mat4 proj) {
|
||||
return glm_persp_aspect_lh_no(proj);
|
||||
}
|
109
src/clipspace/persp_lh_zo.c
Normal file
109
src/clipspace/persp_lh_zo.c
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/clipspace/persp_lh_zo.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_frustum_lh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
glm_frustum_lh_zo(left, right,
|
||||
bottom, top,
|
||||
nearZ, farZ,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_lh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
glm_perspective_lh_zo(fovy,
|
||||
aspect,
|
||||
nearVal,
|
||||
farVal,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_move_far_lh_zo(mat4 proj, float deltaFar) {
|
||||
glm_persp_move_far_lh_zo(proj, deltaFar);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_lh_zo(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right) {
|
||||
glm_persp_decomp_lh_zo(proj, nearZ, farZ, top, bottom, left, right);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decompv_lh_zo(mat4 proj, float dest[6]) {
|
||||
glm_persp_decompv_lh_zo(proj, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_x_lh_zo(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right) {
|
||||
glm_persp_decomp_x_lh_zo(proj, left, right);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_y_lh_zo(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom) {
|
||||
glm_persp_decomp_y_lh_zo(proj, top, bottom);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_z_lh_zo(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ) {
|
||||
glm_persp_decomp_z_lh_zo(proj, nearZ, farZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_far_lh_zo(mat4 proj, float * __restrict farZ) {
|
||||
glm_persp_decomp_far_lh_zo(proj, farZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_near_lh_zo(mat4 proj, float * __restrict nearZ) {
|
||||
glm_persp_decomp_near_lh_zo(proj, nearZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_sizes_lh_zo(mat4 proj, float fovy, vec4 dest) {
|
||||
glm_persp_sizes_lh_zo(proj, fovy, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_fovy_lh_zo(mat4 proj) {
|
||||
return glm_persp_fovy_lh_zo(proj);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_aspect_lh_zo(mat4 proj) {
|
||||
return glm_persp_aspect_lh_zo(proj);
|
||||
}
|
109
src/clipspace/persp_rh_no.c
Normal file
109
src/clipspace/persp_rh_no.c
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/clipspace/persp_rh_no.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_frustum_rh_no(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
glm_frustum_rh_no(left, right,
|
||||
bottom, top,
|
||||
nearZ, farZ,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_rh_no(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
glm_perspective_rh_no(fovy,
|
||||
aspect,
|
||||
nearVal,
|
||||
farVal,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_move_far_rh_no(mat4 proj, float deltaFar) {
|
||||
glm_persp_move_far_rh_no(proj, deltaFar);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_rh_no(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right) {
|
||||
glm_persp_decomp_rh_no(proj, nearZ, farZ, top, bottom, left, right);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decompv_rh_no(mat4 proj, float dest[6]) {
|
||||
glm_persp_decompv_rh_no(proj, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_x_rh_no(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right) {
|
||||
glm_persp_decomp_x_rh_no(proj, left, right);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_y_rh_no(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom) {
|
||||
glm_persp_decomp_y_rh_no(proj, top, bottom);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_z_rh_no(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ) {
|
||||
glm_persp_decomp_z_rh_no(proj, nearZ, farZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_far_rh_no(mat4 proj, float * __restrict farZ) {
|
||||
glm_persp_decomp_far_rh_no(proj, farZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_near_rh_no(mat4 proj, float * __restrict nearZ) {
|
||||
glm_persp_decomp_near_rh_no(proj, nearZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_sizes_rh_no(mat4 proj, float fovy, vec4 dest) {
|
||||
glm_persp_sizes_rh_no(proj, fovy, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_fovy_rh_no(mat4 proj) {
|
||||
return glm_persp_fovy_rh_no(proj);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_aspect_rh_no(mat4 proj) {
|
||||
return glm_persp_aspect_rh_no(proj);
|
||||
}
|
109
src/clipspace/persp_rh_zo.c
Normal file
109
src/clipspace/persp_rh_zo.c
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/clipspace/persp_rh_zo.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_frustum_rh_zo(float left, float right,
|
||||
float bottom, float top,
|
||||
float nearZ, float farZ,
|
||||
mat4 dest) {
|
||||
glm_frustum_rh_zo(left, right,
|
||||
bottom, top,
|
||||
nearZ, farZ,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_perspective_rh_zo(float fovy,
|
||||
float aspect,
|
||||
float nearVal,
|
||||
float farVal,
|
||||
mat4 dest) {
|
||||
glm_perspective_rh_zo(fovy,
|
||||
aspect,
|
||||
nearVal,
|
||||
farVal,
|
||||
dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_move_far_rh_zo(mat4 proj, float deltaFar) {
|
||||
glm_persp_move_far_rh_zo(proj, deltaFar);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_rh_zo(mat4 proj,
|
||||
float * __restrict nearZ, float * __restrict farZ,
|
||||
float * __restrict top, float * __restrict bottom,
|
||||
float * __restrict left, float * __restrict right) {
|
||||
glm_persp_decomp_rh_zo(proj, nearZ, farZ, top, bottom, left, right);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decompv_rh_zo(mat4 proj, float dest[6]) {
|
||||
glm_persp_decompv_rh_zo(proj, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_x_rh_zo(mat4 proj,
|
||||
float * __restrict left,
|
||||
float * __restrict right) {
|
||||
glm_persp_decomp_x_rh_zo(proj, left, right);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_y_rh_zo(mat4 proj,
|
||||
float * __restrict top,
|
||||
float * __restrict bottom) {
|
||||
glm_persp_decomp_y_rh_zo(proj, top, bottom);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_z_rh_zo(mat4 proj,
|
||||
float * __restrict nearZ,
|
||||
float * __restrict farZ) {
|
||||
glm_persp_decomp_z_rh_zo(proj, nearZ, farZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_far_rh_zo(mat4 proj, float * __restrict farZ) {
|
||||
glm_persp_decomp_far_rh_zo(proj, farZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_decomp_near_rh_zo(mat4 proj, float * __restrict nearZ) {
|
||||
glm_persp_decomp_near_rh_zo(proj, nearZ);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_persp_sizes_rh_zo(mat4 proj, float fovy, vec4 dest) {
|
||||
glm_persp_sizes_rh_zo(proj, fovy, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_fovy_rh_zo(mat4 proj) {
|
||||
return glm_persp_fovy_rh_zo(proj);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
float
|
||||
glmc_persp_aspect_rh_zo(mat4 proj) {
|
||||
return glm_persp_aspect_rh_zo(proj);
|
||||
}
|
27
src/clipspace/view_lh_no.c
Normal file
27
src/clipspace/view_lh_no.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
#include "../include/cglm/clipspace/view_lh_no.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_lookat_lh_no(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
glm_lookat_lh_no(eye, center, up, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_lh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
glm_look_lh_no(eye, dir, up, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_anyup_lh_no(vec3 eye, vec3 dir, mat4 dest) {
|
||||
glm_look_anyup_lh_no(eye, dir, dest);
|
||||
}
|
27
src/clipspace/view_lh_zo.c
Normal file
27
src/clipspace/view_lh_zo.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
#include "../include/cglm/clipspace/view_lh_zo.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_lookat_lh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
glm_lookat_lh_zo(eye, center, up, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_lh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
glm_look_lh_zo(eye, dir, up, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_anyup_lh_zo(vec3 eye, vec3 dir, mat4 dest) {
|
||||
glm_look_anyup_lh_zo(eye, dir, dest);
|
||||
}
|
27
src/clipspace/view_rh_no.c
Normal file
27
src/clipspace/view_rh_no.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
#include "../include/cglm/clipspace/view_rh_no.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_lookat_rh_no(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
glm_lookat_rh_no(eye, center, up, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_rh_no(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
glm_look_rh_no(eye, dir, up, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_anyup_rh_no(vec3 eye, vec3 dir, mat4 dest) {
|
||||
glm_look_anyup_rh_no(eye, dir, dest);
|
||||
}
|
27
src/clipspace/view_rh_zo.c
Normal file
27
src/clipspace/view_rh_zo.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#include "../include/cglm/cglm.h"
|
||||
#include "../include/cglm/clipspace/view_rh_zo.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_lookat_rh_zo(vec3 eye, vec3 center, vec3 up, mat4 dest) {
|
||||
glm_lookat_rh_zo(eye, center, up, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_rh_zo(vec3 eye, vec3 dir, vec3 up, mat4 dest) {
|
||||
glm_look_rh_zo(eye, dir, up, dest);
|
||||
}
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_look_anyup_rh_zo(vec3 eye, vec3 dir, mat4 dest) {
|
||||
glm_look_anyup_rh_zo(eye, dir, dest);
|
||||
}
|
@@ -20,6 +20,10 @@
|
||||
# define _GNU_SOURCE /* for drand48() */
|
||||
#endif
|
||||
|
||||
#ifndef CGLM_CLIPSPACE_INCLUDE_ALL
|
||||
# define CGLM_CLIPSPACE_INCLUDE_ALL
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@@ -70,8 +70,35 @@
|
||||
<ClInclude Include="..\include\cglm\call\vec2.h" />
|
||||
<ClInclude Include="..\include\cglm\call\vec3.h" />
|
||||
<ClInclude Include="..\include\cglm\call\vec4.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\ortho_lh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\ortho_lh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\ortho_rh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\ortho_rh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\persp_lh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\persp_lh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\persp_rh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\persp_rh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\view_lh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\view_lh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\view_rh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\call\clipspace\view_rh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\cam.h" />
|
||||
<ClInclude Include="..\include\cglm\cglm.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\ortho_lh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\ortho_lh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\ortho_rh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\ortho_rh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\persp.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\persp_lh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\persp_lh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\persp_rh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\persp_rh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\view_lh.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\view_lh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\view_lh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\view_rh.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\view_rh_no.h" />
|
||||
<ClInclude Include="..\include\cglm\clipspace\view_rh_zo.h" />
|
||||
<ClInclude Include="..\include\cglm\color.h" />
|
||||
<ClInclude Include="..\include\cglm\common.h" />
|
||||
<ClInclude Include="..\include\cglm\curve.h" />
|
||||
|
Reference in New Issue
Block a user