diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-03-31 02:34:19 +1100 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-03-31 02:34:19 +1100 |
commit | 6463c6c1090644438d8449f7ae1a152a4a196123 (patch) | |
tree | a312ff598c85af1a2e9dd65c0fadc08a2891b6ad /src/maths/maths.h | |
parent | c4bf1916fe219324e14384fc938e767daeab26c9 (diff) |
more api design
Diffstat (limited to 'src/maths/maths.h')
-rw-r--r-- | src/maths/maths.h | 23 |
1 files changed, 12 insertions, 11 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 */ |