diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-11 00:13:18 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-11 00:13:18 +1000 |
commit | 87a47aead498d4f7c360d64efc632bcf1a533751 (patch) | |
tree | 7b39d6abcd6d39d76ecaacc0352ad685783a00c7 /src | |
parent | 7bd1560cf2b49018a842fb42cda2c17b347957aa (diff) |
chore: fmt and lint
Diffstat (limited to 'src')
-rw-r--r-- | src/core/core.c | 4 | ||||
-rw-r--r-- | src/maths/maths.h | 2 | ||||
-rw-r--r-- | src/ral/backends/opengl/backend_opengl.c | 3 | ||||
-rw-r--r-- | src/ral/ral_common.c | 12 | ||||
-rw-r--r-- | src/ral/ral_impl.h | 10 | ||||
-rw-r--r-- | src/render/render.h | 10 | ||||
-rw-r--r-- | src/render/shader_layouts.h | 2 | ||||
-rw-r--r-- | src/render/skybox.c | 14 |
8 files changed, 29 insertions, 28 deletions
diff --git a/src/core/core.c b/src/core/core.c index 12aa33f..7d209d5 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -78,6 +78,8 @@ Core* get_global_core() { return &g_core; } GLFWwindow* Core_GetGlfwWindowPtr(Core* core) { return g_core.window; } -struct Renderer* Core_GetRenderer(Core* core) { return core->renderer; } +struct Renderer* Core_GetRenderer(Core* core) { + return core->renderer; +} Model* Model_Get(ModelHandle h) { return Model_pool_get(&g_core.models, h); } diff --git a/src/maths/maths.h b/src/maths/maths.h index 0b3760e..9e71f79 100644 --- a/src/maths/maths.h +++ b/src/maths/maths.h @@ -311,7 +311,7 @@ static Transform transform_create(Vec3 pos, Quat rot, f32 scale) { return (Transform){ .position = pos, .rotation = rot, .scale = scale, .is_dirty = true }; } - Mat4 transform_to_mat(Transform *tf); +Mat4 transform_to_mat(Transform *tf); // --- Sizing asserts diff --git a/src/ral/backends/opengl/backend_opengl.c b/src/ral/backends/opengl/backend_opengl.c index 6c1a301..7862a81 100644 --- a/src/ral/backends/opengl/backend_opengl.c +++ b/src/ral/backends/opengl/backend_opengl.c @@ -57,7 +57,8 @@ bool GPU_Backend_Init(const char* window_name, struct GLFWwindow* window, } // All of these are no-ops in OpenGL -void GPU_Backend_Shutdown() { /* TODO */ } +void GPU_Backend_Shutdown() { /* TODO */ +} bool GPU_Device_Create(GPU_Device* out_device) { return true; } void GPU_Device_Destroy(GPU_Device* device) {} bool GPU_Swapchain_Create(GPU_Swapchain* out_swapchain) { return true; } diff --git a/src/ral/ral_common.c b/src/ral/ral_common.c index 53e35f0..d921ac4 100644 --- a/src/ral/ral_common.c +++ b/src/ral/ral_common.c @@ -61,10 +61,10 @@ size_t VertexAttribSize(VertexAttribType attr) { } size_t VertexDesc_CalcStride(VertexDescription* desc) { - size_t stride = 0; - for (int i = 0; i < desc->attributes_count; i++) { - size_t size =VertexAttribSize(desc->attributes[i]); - stride += size; - } - return stride; + size_t stride = 0; + for (int i = 0; i < desc->attributes_count; i++) { + size_t size = VertexAttribSize(desc->attributes[i]); + stride += size; + } + return stride; } diff --git a/src/ral/ral_impl.h b/src/ral/ral_impl.h index f5a16d2..8f96bc3 100644 --- a/src/ral/ral_impl.h +++ b/src/ral/ral_impl.h @@ -81,10 +81,12 @@ PUB void GPU_EncodeCopyBufToBuf(); // PUB void GPU_EncodeCopyBufToTex(GPU_CmdEncoder* encoder, BufferHandle src, TextureHandle dst, // u32 x_offset, u32 y_offset, u32 width, u32 height, const void* data); -/** @brief Convenience method for writing data directly into a texture. Staging memory is handled internally. */ -PUB void GPU_WriteTextureRegion(GPU_CmdEncoder* encoder, TextureHandle dst, - u32 x_offset, u32 y_offset, u32 width, u32 height, const void* data); -PUB void GPU_WriteBuffer(GPU_CmdEncoder* encoder, BufferHandle buf, u64 offset, u64 size, const void* data); +/** @brief Convenience method for writing data directly into a texture. Staging memory is handled + * internally. */ +PUB void GPU_WriteTextureRegion(GPU_CmdEncoder* encoder, TextureHandle dst, u32 x_offset, + u32 y_offset, u32 width, u32 height, const void* data); +PUB void GPU_WriteBuffer(GPU_CmdEncoder* encoder, BufferHandle buf, u64 offset, u64 size, + const void* data); PUB void GPU_EncodeDraw(GPU_CmdEncoder* encoder, u64 count); PUB void GPU_EncodeDrawIndexed(GPU_CmdEncoder* encoder, u64 index_count); diff --git a/src/render/render.h b/src/render/render.h index 0aee51c..5dc3853 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -3,13 +3,13 @@ */ #pragma once +#include "camera.h" #include "defines.h" #include "grid.h" #include "maths_types.h" #include "ral_types.h" #include "render_types.h" #include "shadows.h" -#include "camera.h" typedef struct Renderer Renderer; typedef struct GLFWwindow GLFWwindow; @@ -78,7 +78,8 @@ MeshHandle Mesh_Insert(Mesh* mesh); MaterialHandle Material_Insert(Material* material); /** @brief gets render entities from a model and pushes them into a dynamic array for rendering */ -size_t ModelExtractRenderEnts(RenderEnt_darray* entities, ModelHandle model_handle, Mat4 affine, RenderEntityFlags flags); +size_t ModelExtractRenderEnts(RenderEnt_darray* entities, ModelHandle model_handle, Mat4 affine, + RenderEntityFlags flags); // --- Drawing @@ -129,8 +130,9 @@ void Render_SetRenderMode(RenderMode mode); // typedef struct Renderer Renderer; -// /** @brief Produces a smaller set of only those meshes visible in the camera frustum on the CPU */ -// Cull_Result Frame_Cull(Renderer* ren, RenderEnt* entities, size_t entity_count, Camera* camera); +// /** @brief Produces a smaller set of only those meshes visible in the camera frustum on the CPU +// */ Cull_Result Frame_Cull(Renderer* ren, RenderEnt* entities, size_t entity_count, Camera* +// camera); // Cull_Result Frame_Cull(Renderer* ren, RenderEnt* entities, size_t entity_count, Camera* camera) { // // TODO: u32 chunk_count = Tpool_GetNumWorkers(); diff --git a/src/render/shader_layouts.h b/src/render/shader_layouts.h index 09cf129..ef94c89 100644 --- a/src/render/shader_layouts.h +++ b/src/render/shader_layouts.h @@ -67,4 +67,4 @@ static ShaderDataLayout Binding_Lights_GetLayout(void* data) { b1.data.bytes.data = d; } return (ShaderDataLayout){ .bindings = { b1 }, .binding_count = 1 }; -}
\ No newline at end of file +} diff --git a/src/render/skybox.c b/src/render/skybox.c index cc5797f..b228c82 100644 --- a/src/render/skybox.c +++ b/src/render/skybox.c @@ -39,7 +39,9 @@ static const char* faces[6] = { "assets/demo/skybox/right.jpg", "assets/demo/sky Skybox Skybox_Create(const char** face_paths, int n) { INFO("Creating a skybox"); - assert(n == 6); // ! we're only supporting a full cubemap for now + CASSERT_MSG( + n == 6, + "We only support full cubemaps for now"); // ! we're only supporting a full cubemap for now // -- cube verts Geometry geom = { .format = VERTEX_POS_ONLY, // doesnt matter @@ -59,12 +61,8 @@ Skybox Skybox_Create(const char** face_paths, int n) { GPU_Texture* tex = GPU_TextureAlloc(&handle); glBindTexture(GL_TEXTURE_CUBE_MAP, tex->id); - int width, height, nrChannels; - // unsigned char *data; for (unsigned int i = 0; i < n; i++) { - TextureData data = TextureDataLoad( - face_paths[i], - false); // stbi_load(textures_faces[i].c_str(), &width, &height, &nrChannels, 0); + TextureData data = TextureDataLoad(face_paths[i], false); assert(data.description.format == TEXTURE_FORMAT_8_8_8_RGB_UNORM); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, data.description.extents.x, data.description.extents.y, 0, GL_RGB, GL_UNSIGNED_BYTE, data.image_data); @@ -91,10 +89,6 @@ Skybox Skybox_Create(const char** face_paths, int n) { ERROR_EXIT("Failed to load shaders from disk") } - // VertexDescription pos_only = { .debug_label = "Position only verts" }; - // VertexDesc_AddAttr(&pos_only, "inPos", ATTR_F32x3); - // pos_only.use_full_vertex_size = true; - ShaderDataLayout camera_data = Binding_Camera_GetLayout(NULL); ShaderDataLayout shader_data = Skybox_GetLayout(NULL); |