From d20356fd426ccea1866fbda798864a378303bbbd Mon Sep 17 00:00:00 2001 From: Omni Date: Sat, 22 Jun 2024 23:29:32 +1000 Subject: chore: format --- examples/pbr_textured/ex_pbr_textured.c | 2 +- examples/shadow_maps/ex_shadow_maps.c | 4 +- src/renderer/backends/opengl/backend_opengl.c | 21 +++--- src/renderer/renderpasses.c | 96 ++++++++++++--------------- src/systems/terrain.c | 6 +- 5 files changed, 58 insertions(+), 71 deletions(-) diff --git a/examples/pbr_textured/ex_pbr_textured.c b/examples/pbr_textured/ex_pbr_textured.c index fa1d555..cbb3a3e 100644 --- a/examples/pbr_textured/ex_pbr_textured.c +++ b/examples/pbr_textured/ex_pbr_textured.c @@ -98,7 +98,7 @@ int main() { encode_set_default_settings(enc); theta += 0.01; - transform transform = { .position = vec3(0,0,0), + transform transform = { .position = vec3(0, 0, 0), .rotation = quat_from_axis_angle(VEC3_Z, theta, true), .scale = 1.0 }; mat4 model_affine = transform_to_mat(&transform); diff --git a/examples/shadow_maps/ex_shadow_maps.c b/examples/shadow_maps/ex_shadow_maps.c index 1423d7a..3b647ee 100644 --- a/examples/shadow_maps/ex_shadow_maps.c +++ b/examples/shadow_maps/ex_shadow_maps.c @@ -41,7 +41,7 @@ int main() { mesh scene[5]; for (int i = 0; i < 4; i++) { - geometry_data geo = geo_create_cuboid(f32x3(2,2,2)); + geometry_data geo = geo_create_cuboid(f32x3(2, 2, 2)); cubes[i] = mesh_create(&geo, true); } @@ -81,7 +81,7 @@ int main() { end_renderpass() */ - + gpu_backend_end_frame(); } diff --git a/src/renderer/backends/opengl/backend_opengl.c b/src/renderer/backends/opengl/backend_opengl.c index ea10acb..00b41b2 100644 --- a/src/renderer/backends/opengl/backend_opengl.c +++ b/src/renderer/backends/opengl/backend_opengl.c @@ -145,11 +145,13 @@ gpu_renderpass* gpu_renderpass_create(const gpu_renderpass_desc* description) { if (description->has_color_target) { gpu_texture* colour_attachment = TEXTURE_GET(description->color_target); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colour_attachment->id, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + colour_attachment->id, 0); } if (description->has_depth_stencil) { gpu_texture* depth_attachment = TEXTURE_GET(description->depth_stencil); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depth_attachment->id, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, + depth_attachment->id, 0); } if (description->has_depth_stencil && !description->has_color_target) { @@ -157,13 +159,11 @@ gpu_renderpass* gpu_renderpass_create(const gpu_renderpass_desc* description) { glReadBuffer(GL_NONE); } - glBindFramebuffer(GL_FRAMEBUFFER, 0); // reset to default framebuffer + glBindFramebuffer(GL_FRAMEBUFFER, 0); // reset to default framebuffer return renderpass; } -void gpu_renderpass_destroy(gpu_renderpass* pass) { - glDeleteFramebuffers(1, &pass->fbo); -} +void gpu_renderpass_destroy(gpu_renderpass* pass) { glDeleteFramebuffers(1, &pass->fbo); } // --- Swapchain bool gpu_swapchain_create(gpu_swapchain* out_swapchain) {} @@ -341,7 +341,8 @@ texture_handle gpu_texture_create(texture_desc desc, bool create_view, const voi glBindTexture(GL_TEXTURE_2D, gl_texture_id); - GLint internal_format = desc.format == CEL_TEXTURE_FORMAT_DEPTH_DEFAULT ? GL_DEPTH_COMPONENT : GL_RGB; + GLint internal_format = + desc.format == CEL_TEXTURE_FORMAT_DEPTH_DEFAULT ? GL_DEPTH_COMPONENT : GL_RGB; GLenum format = desc.format == CEL_TEXTURE_FORMAT_DEPTH_DEFAULT ? GL_DEPTH_COMPONENT : GL_RGBA; GLenum data_type = desc.format == CEL_TEXTURE_FORMAT_DEPTH_DEFAULT ? GL_FLOAT : GL_UNSIGNED_BYTE; @@ -354,14 +355,12 @@ texture_handle gpu_texture_create(texture_desc desc, bool create_view, const voi glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if (data) { - glTexImage2D(GL_TEXTURE_2D, 0, internal_format, desc.extents.x, desc.extents.y, 0, - format, + glTexImage2D(GL_TEXTURE_2D, 0, internal_format, desc.extents.x, desc.extents.y, 0, format, data_type, data); glGenerateMipmap(GL_TEXTURE_2D); } else { WARN("No image data provided"); - glTexImage2D(GL_TEXTURE_2D, 0, internal_format, desc.extents.x, desc.extents.y, 0, - format, + glTexImage2D(GL_TEXTURE_2D, 0, internal_format, desc.extents.x, desc.extents.y, 0, format, data_type, NULL); } diff --git a/src/renderer/renderpasses.c b/src/renderer/renderpasses.c index 3f2152f..e005c14 100644 --- a/src/renderer/renderpasses.c +++ b/src/renderer/renderpasses.c @@ -1,19 +1,19 @@ /** * @file renderpasses.c * @author your name (you@domain.com) - * @brief + * @brief * @version 0.1 * @date 2024-06-22 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "renderpasses.h" +#include "file.h" #include "maths_types.h" #include "ral.h" #include "ral_types.h" -#include "file.h" #define SHADOW_WIDTH 1000 #define SHADOW_HEIGHT 1000 @@ -26,19 +26,15 @@ void ren_shadowmaps_init(ren_shadowmaps* storage) { gpu_renderpass* shadowmaps_renderpass_create() { // Create depthmap texture u32x2 extents = u32x2(SHADOW_WIDTH, SHADOW_HEIGHT); - texture_desc depthmap_desc = { - .extents = extents, - .format = CEL_TEXTURE_FORMAT_DEPTH_DEFAULT, - .tex_type = CEL_TEXTURE_TYPE_2D - }; + texture_desc depthmap_desc = { .extents = extents, + .format = CEL_TEXTURE_FORMAT_DEPTH_DEFAULT, + .tex_type = CEL_TEXTURE_TYPE_2D }; texture_handle depthmap = gpu_texture_create(depthmap_desc, false, NULL); - gpu_renderpass_desc shadows_desc = { - .default_framebuffer = false, - .has_color_target = false, - .has_depth_stencil = true, - .depth_stencil = depthmap - }; + gpu_renderpass_desc shadows_desc = { .default_framebuffer = false, + .has_color_target = false, + .has_depth_stencil = true, + .depth_stencil = depthmap }; return gpu_renderpass_create(&shadows_desc); } @@ -54,30 +50,28 @@ typedef struct lightspace_tf_uniform { shader_data_layout model_uniform_layout(void* data) { bool has_data = data != NULL; - shader_binding b1 = { - .label = "Model", - .type = SHADER_BINDING_BYTES, - .stores_data = has_data, - .data = {.bytes.size = sizeof(model_uniform)} - }; + shader_binding b1 = { .label = "Model", + .type = SHADER_BINDING_BYTES, + .stores_data = has_data, + .data = { .bytes.size = sizeof(model_uniform) } }; if (has_data) { b1.data.bytes.data = data; } - return (shader_data_layout){ .name = "model_uniform", .bindings = {b1}, .bindings_count = 1}; + return (shader_data_layout){ .name = "model_uniform", .bindings = { b1 }, .bindings_count = 1 }; } shader_data_layout lightspace_uniform_layout(void* data) { bool has_data = data != NULL; - shader_binding b1 = { - .label = "LightSpace", - .type = SHADER_BINDING_BYTES, - .stores_data = has_data, - .data = {.bytes.size = sizeof(lightspace_tf_uniform)} - }; + shader_binding b1 = { .label = "LightSpace", + .type = SHADER_BINDING_BYTES, + .stores_data = has_data, + .data = { .bytes.size = sizeof(lightspace_tf_uniform) } }; if (has_data) { b1.data.bytes.data = data; } - return (shader_data_layout){ .name = "lightspace_tf_uniform", .bindings = {b1}, .bindings_count = 1}; + return (shader_data_layout){ .name = "lightspace_tf_uniform", + .bindings = { b1 }, + .bindings_count = 1 }; } // ================== @@ -94,33 +88,27 @@ gpu_pipeline* shadowmaps_pipeline_create(gpu_renderpass* rpass) { } // We'll have two data layouts. 1. for the light-space transform, and 2. for the model matrix - shader_data model_uniform = {.data = NULL, .shader_data_get_layout = &model_uniform_layout }; - shader_data lightspace_uniform = {.data = NULL, .shader_data_get_layout = &lightspace_uniform_layout }; - - struct graphics_pipeline_desc desc = { - .debug_name = "Shadowmap drawing pipeline", - .vertex_desc = static_3d_vertex_description(), - .data_layouts = { model_uniform, lightspace_uniform }, - .data_layouts_count = 2, - .vs = { - .debug_name = "Shadows Vert shader", - .filepath = vert_path, - .code = vertex_shader.contents, - .is_spirv = true - }, - .fs = { - .debug_name = "Shadows Frag shader", - .filepath = vert_path, - .code = vertex_shader.contents, - .is_spirv = true - }, - .renderpass = rpass - }; + shader_data model_uniform = { .data = NULL, .shader_data_get_layout = &model_uniform_layout }; + shader_data lightspace_uniform = { .data = NULL, + .shader_data_get_layout = &lightspace_uniform_layout }; + + struct graphics_pipeline_desc desc = { .debug_name = "Shadowmap drawing pipeline", + .vertex_desc = static_3d_vertex_description(), + .data_layouts = { model_uniform, lightspace_uniform }, + .data_layouts_count = 2, + .vs = { .debug_name = "Shadows Vert shader", + .filepath = vert_path, + .code = vertex_shader.contents, + .is_spirv = true }, + .fs = { .debug_name = "Shadows Frag shader", + .filepath = vert_path, + .code = vertex_shader.contents, + .is_spirv = true }, + .renderpass = rpass }; arena_free_storage(&scratch); return gpu_graphics_pipeline_create(desc); } -void renderpass_shadowmap_execute(gpu_renderpass* pass, render_entity* entities, size_t entity_count) { - -} \ No newline at end of file +void renderpass_shadowmap_execute(gpu_renderpass* pass, render_entity* entities, + size_t entity_count) {} \ No newline at end of file diff --git a/src/systems/terrain.c b/src/systems/terrain.c index 1ff4078..6342d66 100644 --- a/src/systems/terrain.c +++ b/src/systems/terrain.c @@ -1,12 +1,12 @@ /** * @file terrain.c * @author your name (you@domain.com) - * @brief + * @brief * @version 0.1 * @date 2024-06-22 - * + * * @copyright Copyright (c) 2024 - * + * */ #include "terrain.h" #include "ral.h" -- cgit v1.2.3-70-g09d2