Reshuffled

This commit is contained in:
2021-04-19 21:30:34 +10:00
parent eca6c56d00
commit 365a57ff5a
45 changed files with 218 additions and 140 deletions

53
src/display/camera.c Normal file
View File

@ -0,0 +1,53 @@
/**
* Copyright (c) 2021 Dominic Msters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "camera.h"
camera_t * cameraCreate() {
camera_t *camera = malloc(sizeof(camera_t));
if(!camera) return NULL;
return camera;
}
void cameraDispose(camera_t *camera) {
free(camera);
}
void cameraLookAt(camera_t *camera,
float x, float y, float z, float targetX, float targetY, float targetZ
) {
glm_lookat(
(vec3){ x, y, z },
(vec3){ targetX, targetY, targetZ },
(vec3){ 0, 1, 0 },
camera->view
);
}
void cameraLook(camera_t *camera,
float x, float y, float z,
float pitch, float yaw, float roll
) {
glm_look(
(vec3){ x, y, z },
(vec3){ pitch, yaw, roll },
(vec3){ 0, 1, 0 },
camera->view
);
}
void cameraPerspective(camera_t *camera,
float fov, float aspect, float near, float far
) {
glm_perspective(fov, aspect, near, far, camera->projection);
}
void cameraOrtho(camera_t *camera,
float left, float right, float bottom, float top, float near, float far
) {
glm_ortho(left, right, bottom, top, near, far, camera->projection);
}