Added matrix

This commit is contained in:
2021-07-12 10:22:33 -07:00
parent 9bdd7057f2
commit 06a20a6f2e
11 changed files with 250 additions and 64 deletions

62
src/display/matrix.c Normal file
View 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 });
}