summaryrefslogtreecommitdiff
path: root/src/engine/M_camera.c
blob: 58414a7d6ff74e205839185133d19c5ebdeb2018 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "M_camera.h"

void M_initCamera(M_Camera *camera, vec3 up)
{
	glm_vec3_zero(camera->pos);
	glm_vec3_copy(
			up,
			camera->up
			);
	glm_vec3_copy(
			(vec3){0.0f, 0.0f, -1.0f},
			camera->direction
			);
}

inline void M_cameraViewMatrix(M_Camera* camera)
{
	vec3 target;
	glm_vec3_add(
			camera->pos,
			camera->direction,
			target
			);
	glm_lookat(
			camera->pos,
			target,
			camera->up,
			camera->view_matrix
			);
}