summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOmni <omniscient.oce@gmail.com>2024-06-22 23:29:32 +1000
committerOmni <omniscient.oce@gmail.com>2024-06-22 23:29:32 +1000
commitd20356fd426ccea1866fbda798864a378303bbbd (patch)
treea2a820e43671ba4022dc23c2462b52423f999f9b /src
parent39e7122b5cd1e0d56a4a7cfd3c4114032d14e9b6 (diff)
chore: format
Diffstat (limited to 'src')
-rw-r--r--src/renderer/backends/opengl/backend_opengl.c21
-rw-r--r--src/renderer/renderpasses.c96
-rw-r--r--src/systems/terrain.c6
3 files changed, 55 insertions, 68 deletions
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"