summaryrefslogtreecommitdiff
path: root/src/camera.c
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-18 12:55:02 +1100
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-18 12:55:02 +1100
commitf5190745aed65b231e380fa3f25fce46d220dcbc (patch)
treef363f5c4b8e1e182609702c5a78e23da0a5b4558 /src/camera.c
parentde17d20f1848774f854903dcce40cd1e33b1cad9 (diff)
removing some outdated docs files
Diffstat (limited to 'src/camera.c')
-rw-r--r--src/camera.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/camera.c b/src/camera.c
new file mode 100644
index 0000000..79f9c19
--- /dev/null
+++ b/src/camera.c
@@ -0,0 +1,15 @@
+#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