summaryrefslogtreecommitdiff
path: root/src/maths
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-31 02:34:19 +1100
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-31 02:34:19 +1100
commit6463c6c1090644438d8449f7ae1a152a4a196123 (patch)
treea312ff598c85af1a2e9dd65c0fadc08a2891b6ad /src/maths
parentc4bf1916fe219324e14384fc938e767daeab26c9 (diff)
more api design
Diffstat (limited to 'src/maths')
-rw-r--r--src/maths/maths.h23
-rw-r--r--src/maths/maths_types.h6
-rw-r--r--src/maths/primitives.h2
3 files changed, 18 insertions, 13 deletions
diff --git a/src/maths/maths.h b/src/maths/maths.h
index 9206c5c..6fa2f9b 100644
--- a/src/maths/maths.h
+++ b/src/maths/maths.h
@@ -134,20 +134,21 @@ static inline mat4 mat4_mult(mat4 lhs, mat4 rhs) {
#if defined(CEL_REND_BACKEND_VULKAN)
/** @brief Creates a perspective projection matrix compatible with Vulkan */
-static inline mat4 mat4_perspective(f32 fov_radians, f32 aspect_ratio, f32 near_clip, f32 far_clip) {
- // near_clip *= -1.0;
- // far_clip *= -1.0;
-
- f32 half_tan_fov = tanf(fov_radians * 0.5f);
- mat4 out_matrix = { .data = { 0 } };
-
- out_matrix.data[0] = 1.0f / (aspect_ratio * half_tan_fov);
- out_matrix.data[5] = -1.0f / half_tan_fov; // Flip Y-axis for Vulkan
- out_matrix.data[10] = -((far_clip + near_clip) / (far_clip - near_clip));
+static inline mat4 mat4_perspective(f32 fov_radians, f32 aspect_ratio, f32 near_clip,
+ f32 far_clip) {
+ // near_clip *= -1.0;
+ // far_clip *= -1.0;
+
+ f32 half_tan_fov = tanf(fov_radians * 0.5f);
+ mat4 out_matrix = { .data = { 0 } };
+
+ out_matrix.data[0] = 1.0f / (aspect_ratio * half_tan_fov);
+ out_matrix.data[5] = -1.0f / half_tan_fov; // Flip Y-axis for Vulkan
+ out_matrix.data[10] = -((far_clip + near_clip) / (far_clip - near_clip));
out_matrix.data[11] = -1.0f;
out_matrix.data[14] = -((2.0f * far_clip * near_clip) / (far_clip - near_clip));
- return out_matrix;
+ return out_matrix;
}
#else
/** @brief Creates a perspective projection matrix */
diff --git a/src/maths/maths_types.h b/src/maths/maths_types.h
index ba741b9..6d38fc7 100644
--- a/src/maths/maths_types.h
+++ b/src/maths/maths_types.h
@@ -60,4 +60,8 @@ typedef struct transform {
quat rotation;
f32 scale;
bool is_dirty;
-} transform; \ No newline at end of file
+} transform;
+
+typedef struct vec4i {
+ i32 x, y, z, w;
+} vec4i; \ No newline at end of file
diff --git a/src/maths/primitives.h b/src/maths/primitives.h
index 60d36da..fd798c1 100644
--- a/src/maths/primitives.h
+++ b/src/maths/primitives.h
@@ -55,7 +55,7 @@ static mesh prim_cube_mesh_create() {
/** @brief create a new model with the shape of a cube */
static model_handle prim_cube_new(core* core) {
- model model = { 0 };
+ model model = { 0 };
mesh cube = prim_cube_mesh_create();
mesh_darray_push(model.meshes, cube);