Added matrix
This commit is contained in:
62
src/display/matrix.c
Normal file
62
src/display/matrix.c
Normal file
@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Copyright (c) 2021 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "matrix.h"
|
||||
|
||||
void matrixIdentity(matrix_t *matrix) {
|
||||
glm_mat4_identity(matrix->internalMatrix);
|
||||
}
|
||||
|
||||
void matrixLookAt(matrix_t *matrix,
|
||||
float x,float y,float z,
|
||||
float tx,float ty, float tz,
|
||||
float ux, float uy, float uz
|
||||
) {
|
||||
glm_lookat(
|
||||
(vec3){ x, y, z },
|
||||
(vec3){ tx, ty, tz },
|
||||
(vec3){ ux, uy, uz },
|
||||
matrix->internalMatrix
|
||||
);
|
||||
}
|
||||
|
||||
void matrixLook(matrix_t *matrix,
|
||||
float x, float y, float z,
|
||||
float pitch, float yaw, float roll,
|
||||
float ux, float uy, float uz
|
||||
) {
|
||||
glm_look(
|
||||
(vec3){ x, y, z },
|
||||
(vec3){ pitch, yaw, roll },
|
||||
(vec3){ ux, uy, uz },
|
||||
matrix->internalMatrix
|
||||
);
|
||||
}
|
||||
|
||||
void matrixPerspective(matrix_t *matrix,
|
||||
float fov,float aspect,float near,float far
|
||||
) {
|
||||
glm_perspective(fov, aspect, near, far, matrix->internalMatrix);
|
||||
}
|
||||
|
||||
void matrixOrtho(matrix_t *matrix,
|
||||
float left, float right, float bottom, float top, float near, float far
|
||||
) {
|
||||
glm_ortho(left, right, bottom, top, near, far, matrix->internalMatrix);
|
||||
}
|
||||
|
||||
void matrixTranslate(matrix_t *matrix, float x, float y, float z) {
|
||||
glm_translate(matrix->internalMatrix, (vec3){ x, y, z });
|
||||
}
|
||||
|
||||
void matrixRotate(matrix_t *matrix, float angle, float x, float y, float z) {
|
||||
glm_rotate(matrix->internalMatrix, angle, (vec3){ x, y, z });
|
||||
}
|
||||
|
||||
void matrixScale(matrix_t *matrix, float x, float y, float z) {
|
||||
glm_scale(MATRIX_POSITION, (vec3){ x, y, z });
|
||||
}
|
Reference in New Issue
Block a user