mat4.h (1168B)
1 2 #ifndef MAT4_H 3 #define MAT4_H 4 5 #include <string.h> 6 7 typedef float mat4; 8 9 #define M_X 12 10 #define M_Y 13 11 #define M_Z 14 12 13 14 /* mat4 *mat4_create_transform(mat4 *a, float *pos, float *scale, float *rot); */ 15 mat4 *mat4_scale(mat4 *a, float v[3], mat4 *out); 16 mat4 *mat4_frustum (float left, float right, float bottom, 17 float top, float near, float far, mat4 *dest); 18 19 mat4 *mat4_perspective(float fov, float aspect, float near, 20 float far, mat4 *dest); 21 22 mat4 *mat4_ortho(float left, float right, float bottom, float top, float near, 23 float far, mat4 *dest); 24 25 mat4 *mat4_translate (mat4 *mat, float *vec3, mat4 *dest); 26 mat4 *mat4_transpose(mat4 *src, mat4 *dest); 27 mat4 *mat4_inverse(mat4 *src, mat4 *dest); 28 mat4 *mat4_id(mat4 *dest); 29 mat4 *mat4_multiply(const mat4 *a, const mat4 *b, mat4 *dest); 30 void mat4_print(const mat4 *a); 31 32 mat4 *mat4_rotate(const mat4 *mat, const float angle, 33 const float *v3_axis, mat4 *dest); 34 35 36 mat4 *mat4_remove_translations(mat4 *mat); 37 38 static inline mat4 *mat4_copy(const mat4 *src, mat4 *dst) 39 { 40 memcpy(dst, src, sizeof(float) * 16); 41 return dst; 42 } 43 44 45 #endif /* MAT4_H */