diff options
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | src/camera.h | 3 | ||||
-rw-r--r-- | src/maths/maths.h | 15 | ||||
-rw-r--r-- | src/renderer/render.h | 8 | ||||
-rw-r--r-- | src/renderer/render_backend.h | 4 |
5 files changed, 15 insertions, 18 deletions
@@ -17,4 +17,5 @@ All third-party dependencies are licensed under their own license. * Formatting * `xmake format` * Lint (no change) `find src/ -iname *.h -o -iname *.c | xargs clang-format --style=file --dry-run --Werror` - * Format (edit in place) `find src/ -iname *.h -o -iname *.c | xargs clang-format -i --style=file`
\ No newline at end of file + * Format (edit in place) `find src/ \( -iname "*.h" -o -iname "*.c" \) | xargs clang-format -i --style=file` + * `clang-format` must be installed!
\ No newline at end of file diff --git a/src/camera.h b/src/camera.h index df91712..f7bc6eb 100644 --- a/src/camera.h +++ b/src/camera.h @@ -23,4 +23,5 @@ typedef struct camera { camera camera_create(vec3 pos, vec3 front, vec3 up, f32 fov); /** @brief get a 4x4 transform matrix for the view and perspective projection */ -void camera_view_projection(camera *c, f32 screen_height, f32 screen_width,mat4 *out_view, mat4 *out_proj);
\ No newline at end of file +void camera_view_projection(camera *c, f32 screen_height, f32 screen_width, mat4 *out_view, + mat4 *out_proj);
\ No newline at end of file diff --git a/src/maths/maths.h b/src/maths/maths.h index fb1bba7..d832739 100644 --- a/src/maths/maths.h +++ b/src/maths/maths.h @@ -20,7 +20,7 @@ // Dimension 3 static inline vec3 vec3_create(f32 x, f32 y, f32 z) { return (vec3){ x, y, z }; } -#define vec3(x,y,z) (vec3_create(x, y, z)) +#define vec3(x, y, z) (vec3_create(x, y, z)) static inline vec3 vec3_add(vec3 a, vec3 b) { return (vec3){ a.x + b.x, a.y + b.y, a.z + b.z }; } static inline vec3 vec3_sub(vec3 a, vec3 b) { return (vec3){ a.x - b.x, a.y - b.y, a.z - b.z }; } static inline vec3 vec3_mult(vec3 a, f32 s) { return (vec3){ a.x * s, a.y * s, a.z * s }; } @@ -56,20 +56,15 @@ static inline vec2 vec2_create(f32 x, f32 y) { return (vec2){ x, y }; } // --- Quaternion Implementations -static inline f32 quat_dot(quat a, quat b) { - return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; -} +static inline f32 quat_dot(quat a, quat b) { return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w; } static inline quat quat_normalise(quat a) { - f32 length = sqrtf( - quat_dot(a, a) // same as len squared + f32 length = sqrtf(quat_dot(a, a) // same as len squared ); - return (quat) { a.x/length, a.y/length,a.z/length,a.w/length }; + return (quat){ a.x / length, a.y / length, a.z / length, a.w / length }; } -static inline quat quat_ident() { - return (quat) { .x = 0.0, .y = 0.0, .z = 0.0, .w = 1.0 }; -} +static inline quat quat_ident() { return (quat){ .x = 0.0, .y = 0.0, .z = 0.0, .w = 1.0 }; } // --- Matrix Implementations diff --git a/src/renderer/render.h b/src/renderer/render.h index 65ace4e..35c2d91 100644 --- a/src/renderer/render.h +++ b/src/renderer/render.h @@ -27,10 +27,10 @@ void texture_data_upload(texture* tex); // #backend // --- Uniforms /** @brief upload a vec3 of f32 to a uniform */ -void uniform_vec3f(u32 program_id, const char *uniform_name, vec3 *value); +void uniform_vec3f(u32 program_id, const char* uniform_name, vec3* value); /** @brief upload a single f32 to a uniform */ -void uniform_f32(u32 program_id, const char *uniform_name, f32 value); +void uniform_f32(u32 program_id, const char* uniform_name, f32 value); /** @brief upload a integer to a uniform */ -void uniform_i32(u32 program_id, const char *uniform_name, i32 value); +void uniform_i32(u32 program_id, const char* uniform_name, i32 value); /** @brief upload a mat4 of f32 to a uniform */ -void uniform_mat4f(u32 program_id, const char *uniform_name, mat4 *value);
\ No newline at end of file +void uniform_mat4f(u32 program_id, const char* uniform_name, mat4* value);
\ No newline at end of file diff --git a/src/renderer/render_backend.h b/src/renderer/render_backend.h index a524f7f..7e1c16c 100644 --- a/src/renderer/render_backend.h +++ b/src/renderer/render_backend.h @@ -12,11 +12,11 @@ void gfx_backend_shutdown(renderer* ren); void clear_screen(vec3 colour); -void bind_texture(shader s, texture *tex, u32 slot); +void bind_texture(shader s, texture* tex, u32 slot); void bind_mesh_vertex_buffer(void* backend, mesh* mesh); void draw_primitives(cel_primitive_topology primitive, u32 start_index, u32 count); -shader shader_create_separate(const char *vert_shader, const char *frag_shader); +shader shader_create_separate(const char* vert_shader, const char* frag_shader); void set_shader(shader s); // --- Uniforms |