mirror of
https://github.com/recp/cglm.git
synced 2025-12-24 12:32:40 +00:00
add new matrix mat4x2
Initial function being glm_mat4x2_make Signed-off-by: Vincent Davis Jr <vince@underview.tech>
This commit is contained in:
@@ -25,6 +25,7 @@ extern "C" {
|
||||
#include "call/mat3x2.h"
|
||||
#include "call/mat3x4.h"
|
||||
#include "call/mat4.h"
|
||||
#include "call/mat4x2.h"
|
||||
#include "call/affine.h"
|
||||
#include "call/cam.h"
|
||||
#include "call/quat.h"
|
||||
|
||||
23
include/cglm/call/mat4x2.h
Normal file
23
include/cglm/call/mat4x2.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
#ifndef cglmc_mat4x2_h
|
||||
#define cglmc_mat4x2_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../cglm.h"
|
||||
|
||||
CGLM_EXPORT
|
||||
void
|
||||
glmc_mat4x2_make(float * __restrict src, mat4x2 dest);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* cglmc_mat4x2_h */
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "ivec3.h"
|
||||
#include "ivec4.h"
|
||||
#include "mat4.h"
|
||||
#include "mat4x2.h"
|
||||
#include "mat3.h"
|
||||
#include "mat3x2.h"
|
||||
#include "mat3x4.h"
|
||||
|
||||
49
include/cglm/mat4x2.h
Normal file
49
include/cglm/mat4x2.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c), Recep Aslantas.
|
||||
*
|
||||
* MIT License (MIT), http://opensource.org/licenses/MIT
|
||||
* Full license can be found in the LICENSE file
|
||||
*/
|
||||
|
||||
/*
|
||||
Macros:
|
||||
GLM_MAT4X2_ZERO_INIT
|
||||
GLM_MAT4X2_ZERO
|
||||
|
||||
Functions:
|
||||
CGLM_INLINE void glm_mat4x2_make(float * restrict src, mat4x2 dest)
|
||||
*/
|
||||
|
||||
#ifndef cglm_mat4x2_h
|
||||
#define cglm_mat4x2_h
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define GLM_MAT4X2_ZERO_INIT {{0.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, 0.0f}, {0.0f, 0.0f}}
|
||||
|
||||
/* for C only */
|
||||
#define GLM_MAT4X2_ZERO GLM_MAT4X2_ZERO_INIT
|
||||
|
||||
/*!
|
||||
* @brief Create mat4x2 matrix from pointer
|
||||
*
|
||||
* @param[in] src pointer to an array of floats
|
||||
* @param[out] dest matrix
|
||||
*/
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_mat4x2_make(float * __restrict src, mat4x2 dest) {
|
||||
dest[0][0] = src[0];
|
||||
dest[0][1] = src[1];
|
||||
|
||||
dest[1][0] = src[2];
|
||||
dest[1][1] = src[3];
|
||||
|
||||
dest[2][0] = src[4];
|
||||
dest[2][1] = src[5];
|
||||
|
||||
dest[3][0] = src[6];
|
||||
dest[3][1] = src[7];
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -23,6 +23,7 @@ extern "C" {
|
||||
#include "struct/mat3x2.h"
|
||||
#include "struct/mat3x4.h"
|
||||
#include "struct/mat4.h"
|
||||
#include "struct/mat4x2.h"
|
||||
#include "struct/affine.h"
|
||||
#include "struct/frustum.h"
|
||||
#include "struct/plane.h"
|
||||
|
||||
46
include/cglm/struct/mat4x2.h
Normal file
46
include/cglm/struct/mat4x2.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
|
||||
*/
|
||||
|
||||
/*
|
||||
Macros:
|
||||
GLMS_MAT4X2_ZERO_INIT
|
||||
GLMS_MAT4X2_ZERO
|
||||
|
||||
Functions:
|
||||
CGLM_INLINE mat4x2s glms_mat4x2_make(float * __restrict src);
|
||||
*/
|
||||
|
||||
#ifndef cglms_mat4x2_h
|
||||
#define cglms_mat4x2_h
|
||||
|
||||
#include "../common.h"
|
||||
#include "../types-struct.h"
|
||||
#include "../mat4x2.h"
|
||||
|
||||
/* api definition */
|
||||
#define glms_mat4x2_(NAME) CGLM_STRUCTAPI(mat4x2, NAME)
|
||||
|
||||
#define GLMS_MAT4X2_ZERO_INIT {GLM_MAT4X2_ZERO_INIT}
|
||||
|
||||
/* for C only */
|
||||
#define GLMS_MAT4X2_ZERO ((mat4x2s)GLMS_MAT4X2_ZERO_INIT)
|
||||
|
||||
/*!
|
||||
* @brief Create mat4x2 matrix from pointer
|
||||
*
|
||||
* @param[in] src pointer to an array of floats
|
||||
* @return constructed matrix from raw pointer
|
||||
*/
|
||||
CGLM_INLINE
|
||||
mat4x2s
|
||||
glms_mat4x2_(make)(float * __restrict src) {
|
||||
mat4x2s r;
|
||||
glm_mat4x2_make(src, r.raw);
|
||||
return r;
|
||||
}
|
||||
|
||||
#endif /* cglms_mat4x2_h */
|
||||
@@ -268,4 +268,17 @@ typedef union CGLM_ALIGN_MAT mat4s {
|
||||
#endif
|
||||
} mat4s;
|
||||
|
||||
typedef union mat4x2s {
|
||||
mat4x2 raw;
|
||||
vec2s col[4]; /* [col (4), row (2)] */
|
||||
#if CGLM_USE_ANONYMOUS_STRUCT
|
||||
struct {
|
||||
float m00, m01;
|
||||
float m10, m11;
|
||||
float m21, m22;
|
||||
float m31, m32;
|
||||
};
|
||||
#endif
|
||||
} mat4x2s;
|
||||
|
||||
#endif /* cglm_types_struct_h */
|
||||
|
||||
@@ -61,6 +61,7 @@ typedef CGLM_ALIGN_IF(16) vec2 mat2[2];
|
||||
typedef vec3 mat2x3[2]; /* [col (2), row (3)] */
|
||||
typedef vec4 mat2x4[2]; /* [col (2), row (4)] */
|
||||
typedef CGLM_ALIGN_MAT vec4 mat4[4];
|
||||
typedef vec2 mat4x2[4]; /* [col (4), row (2)] */
|
||||
|
||||
/*
|
||||
Important: cglm stores quaternion as [x, y, z, w] in memory since v0.4.0
|
||||
|
||||
Reference in New Issue
Block a user