diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-19 13:24:31 +1100 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-19 13:24:31 +1100 |
commit | 6182860f1b1aba4128b4f66eda7977600e60d1a0 (patch) | |
tree | 388d9aff8ca19ef324633ac1bea43f1548675150 /src/camera.c | |
parent | 5d1750d9adfc45b53c75310c58e31dfdbd8a6e15 (diff) | |
parent | d6d742f8a24490f885e4a1ae3fea7ec46b01f58c (diff) |
fix merge
Diffstat (limited to 'src/camera.c')
-rw-r--r-- | src/camera.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/camera.c b/src/camera.c new file mode 100644 index 0000000..eb8fc7d --- /dev/null +++ b/src/camera.c @@ -0,0 +1,13 @@ +#include <celeritas.h> + +mat4 camera_view_proj(camera camera, f32 lens_height, f32 lens_width, mat4* out_view, mat4* out_proj) { + mat4 projection_matrix = mat4_perspective(camera.fov, lens_width / lens_height, 0.1, 1000.0); + // TODO: store near/far on camera rather than hard-coding here. + + vec3 camera_direction = vec3_add(camera.position, camera.forwards); + mat4 view_matrix = mat4_look_at(camera.position, camera_direction, camera.up); + if (out_view) *out_view = view_matrix; + if (out_proj) *out_proj = projection_matrix; + + return mat4_mult(view_matrix, projection_matrix); +}
\ No newline at end of file |