summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-05 12:43:38 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-10-05 12:43:38 +1000
commit54354e32c6498cc7f8839ab4deb1208d37216cc5 (patch)
tree7759597b971ba59d6af841a5bed793c229dd4c2b /src
parentbe8ab99b38c25e899008582d68e891150b328a4d (diff)
Begin simplifying project structure and removing examples
Diffstat (limited to 'src')
-rw-r--r--src/core/animation.c0
-rw-r--r--src/core/core.h2
-rw-r--r--src/core/input.c0
-rw-r--r--src/defines.h81
-rw-r--r--src/maths/maths_types.h13
-rw-r--r--src/ral/ral_types.h118
-rw-r--r--src/render/render_types.h14
7 files changed, 3 insertions, 225 deletions
diff --git a/src/core/animation.c b/src/core/animation.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/core/animation.c
diff --git a/src/core/core.h b/src/core/core.h
index be44b8c..14ba65d 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -18,7 +18,7 @@ typedef struct Core {
GLFWwindow* window;
Renderer* renderer;
Input_State input;
- Model_pool models;
+ // Model_pool models;
} Core;
extern Core g_core;
diff --git a/src/core/input.c b/src/core/input.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/core/input.c
diff --git a/src/defines.h b/src/defines.h
deleted file mode 100644
index 0c0dcac..0000000
--- a/src/defines.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * @file defines.h
- * @brief Typedefs for common integer/floating point types and very basic macros
- * @date 2024-02-24
- */
-#pragma once
-
-#include <stdbool.h>
-#include <stddef.h>
-#include <stdint.h>
-
-typedef uint8_t u8;
-typedef uint16_t u16;
-typedef uint32_t u32;
-typedef uint64_t u64;
-
-typedef int8_t i8;
-typedef int16_t i16;
-typedef int32_t i32;
-typedef int64_t i64;
-
-typedef float f32;
-typedef double f64;
-
-_Static_assert(sizeof(bool) == 1, "type bool should be 1 byte");
-
-_Static_assert(sizeof(u8) == 1, "type u8 should be 1 byte");
-_Static_assert(sizeof(u16) == 2, "type u16 should be 2 byte");
-_Static_assert(sizeof(u32) == 4, "type u32 should be 4 byte");
-_Static_assert(sizeof(u64) == 8, "type u64 should be 8 byte");
-
-_Static_assert(sizeof(i8) == 1, "type i8 should be 1 byte");
-_Static_assert(sizeof(i16) == 2, "type i16 should be 2 byte");
-_Static_assert(sizeof(i32) == 4, "type i32 should be 4 byte");
-_Static_assert(sizeof(i64) == 8, "type i64 should be 8 byte");
-
-_Static_assert(sizeof(f32) == 4, "type f32 should be 4 bytes");
-_Static_assert(sizeof(f64) == 8, "type f64 should be 8 bytes");
-
-_Static_assert(sizeof(ptrdiff_t) == 8, "type ptrdiff_t should be 8 bytes");
-
-#define alignof(x) _Alignof(x)
-
-#define threadlocal _Thread_local
-
-// Wrap a u32 to make a type-safe "handle" or ID
-#define CORE_DEFINE_HANDLE(name) \
- typedef struct name name; \
- struct name { \
- u32 raw; \
- }
-
-CORE_DEFINE_HANDLE(
- Handle); // Untyped handle that can be casted to a strongly typed resource handle
-
-#define PUB // For collecting public APIs to expose in an amalgamation header file
-// #define c_static_inline static inline
-#define c_static_inline
-
-#define KB(x) ((size_t)x * 1000)
-#define MB(x) ((size_t)x * 1000 * 1000)
-#define GB(x) ((size_t)x * 1000 * 1000 * 1000)
-
-// NOTE: The below is now handled in xmake.lua
-// Platform will inform renderer backend (unless user overrides)
-#if defined(CEL_PLATFORM_LINUX)
-#define CEL_REND_BACKEND_OPENGL 1
-// #define CEL_REND_BACKEND_VULKAN 1
-#endif
-
-#if defined(CEL_PLATFORM_WINDOWS)
-#define CEL_REND_BACKEND_OPENGL 1
-// #define CEL_REND_BACKEND_DX11 1
-// #define CEL_REND_BACKEND_VULKAN 1
-#endif
-
-#if defined(CEL_PLATFORM_MAC)
-// #define CEL_REND_BACKEND_METAL 1
-#define CEL_REND_BACKEND_OPENGL 1
-// #define CEL_REND_BACKEND_VULKAN 1
-#endif
diff --git a/src/maths/maths_types.h b/src/maths/maths_types.h
index ef1fe4a..66d260d 100644
--- a/src/maths/maths_types.h
+++ b/src/maths/maths_types.h
@@ -21,19 +21,6 @@ typedef struct Vec2 {
f32 x, y;
} Vec2;
-/** @brief 3D Vector */
-typedef struct Vec3 {
- f32 x, y, z;
-} Vec3;
-
-/** @brief 4D Vector */
-typedef struct Vec4 {
- f32 x, y, z, w;
-} Vec4;
-
-/** @brief Quaternion */
-typedef Vec4 Quat;
-
/** @brief 4x4 Matrix */
typedef struct Mat4 {
// TODO: use this format for more readable code: vec4 x_axis, y_axis, z_axis, w_axis;
diff --git a/src/ral/ral_types.h b/src/ral/ral_types.h
index 1f98e88..fde3bed 100644
--- a/src/ral/ral_types.h
+++ b/src/ral/ral_types.h
@@ -45,15 +45,6 @@ typedef enum GPU_BufferFlag {
} GPU_BufferFlag;
typedef u32 GPU_BufferFlags;
-// --- Textures
-typedef enum GPU_TextureType {
- TEXTURE_TYPE_2D,
- TEXTURE_TYPE_3D,
- TEXTURE_TYPE_2D_ARRAY,
- TEXTURE_TYPE_CUBE_MAP,
- TEXTURE_TYPE_COUNT
-} GPU_TextureType;
-
static const char* texture_type_names[] = {
"RAL Texture 2D", "RAL Texture 3D", "RAL Texture 2D Array",
"RAL Texture Cubemap", "RAL Texture Count",
@@ -66,14 +57,6 @@ typedef enum GPU_TextureFormat {
TEXTURE_FORMAT_COUNT
} GPU_TextureFormat;
-/** @brief Texture Description - used by texture creation functions */
-typedef struct TextureDesc {
- GPU_TextureType tex_type;
- GPU_TextureFormat format;
- u32x2 extents;
- u32 num_channels;
-} TextureDesc;
-
// --- Vertices
typedef enum VertexFormat {
@@ -86,45 +69,6 @@ typedef enum VertexFormat {
VERTEX_COUNT
} VertexFormat;
-typedef union Vertex {
- struct {
- Vec3 position;
- Vec3 normal;
- Vec2 tex_coords;
- } static_3d; /** @brief standard vertex format for static geometry in 3D */
-
- struct {
- Vec2 position;
- Vec4 colour;
- Vec2 tex_coords;
- } sprite; /** @brief vertex format for 2D sprites or quads */
-
- struct {
- Vec3 position;
- Vec4 colour;
- Vec2 tex_coords;
- Vec3 normal;
- Vec4i bone_ids; // Integer vector for bone IDs
- Vec4 bone_weights; // Weight of each bone's influence
- } skinned_3d; /** @brief vertex format for skeletal (animated) geometry in 3D */
-
- struct {
- Vec3 position;
- Vec2 tex_coords;
- Vec3 normal;
- Vec4 colour;
- } coloured_static_3d; /** @brief vertex format used for debugging */
-
- struct {
- Vec2 position;
- Vec3 colour;
- } raw_pos_colour;
-
- struct {
- Vec3 position;
- } pos_only;
-} Vertex;
-
#ifndef TYPED_VERTEX_ARRAY
KITC_DECL_TYPED_ARRAY(Vertex);
KITC_DECL_TYPED_ARRAY(u32)
@@ -162,12 +106,6 @@ typedef enum PipelineKind {
PIPELINE_COMPUTE,
} PipelineKind;
-typedef enum ShaderVisibility {
- VISIBILITY_VERTEX = 1 << 0,
- VISIBILITY_FRAGMENT = 1 << 1,
- VISIBILITY_COMPUTE = 1 << 2,
-} ShaderVisibility;
-
typedef struct ShaderDesc {
const char* debug_name;
Str8 filepath; // Where it came from
@@ -176,39 +114,6 @@ typedef struct ShaderDesc {
bool is_combined_vert_frag; // Contains both vertex and fragment stages
} ShaderDesc;
-typedef enum ShaderBindingKind {
- BINDING_BYTES,
- BINDING_BUFFER,
- BINDING_BUFFER_ARRAY,
- BINDING_TEXTURE,
- BINDING_TEXTURE_ARRAY,
- BINDING_SAMPLER,
- BINDING_COUNT
-} ShaderBindingKind;
-
-typedef struct ShaderBinding {
- const char* label;
- ShaderBindingKind kind;
- ShaderVisibility vis;
- union {
- struct {
- u32 size;
- void* data;
- } bytes;
- struct {
- BufferHandle handle;
- } buffer;
- struct {
- TextureHandle handle;
- } texture;
- } data;
-} ShaderBinding;
-
-typedef struct ShaderDataLayout {
- ShaderBinding bindings[MAX_SHADER_BINDINGS];
- size_t binding_count;
-} ShaderDataLayout;
-
typedef ShaderDataLayout (*FN_GetBindingLayout)(void* data);
/** @brief takes a `ShaderDataLayout` without data, and puts the correct data into each binding */
@@ -219,10 +124,6 @@ typedef void (*FN_BindShaderData)(ShaderDataLayout* layout, const void* data);
// void* data;
// } ShaderData;
-// --- Miscellaneous
-
-#define TOPOLOGY_SHORT_NAMES
-
typedef enum PrimitiveTopology {
#ifdef TOPOLOGY_SHORT_NAMES
CEL_POINT,
@@ -241,8 +142,6 @@ typedef enum PrimitiveTopology {
#endif
} PrimitiveTopology;
-typedef enum CullMode { CULL_BACK_FACE, CULL_FRONT_FACE, CULL_COUNT } CullMode;
-
typedef enum Winding { WINDING_CCW, WINDING_CW } Winding;
// based on https://registry.khronos.org/OpenGL-Refpages/gl4/html/glDepthFunc.xhtml
@@ -258,23 +157,6 @@ typedef enum CompareFunc {
COMPARE_COUNT
} CompareFunc;
-typedef struct GraphicsPipelineDesc {
- const char* debug_name;
- VertexDescription vertex_desc;
- ShaderDesc vs; /** @brief Vertex shader stage */
- ShaderDesc fs; /** @brief Fragment shader stage */
-
- // Roughly equivalent to a descriptor set layout each. each layout can have multiple bindings
- // examples:
- // - uniform buffer representing view projection matrix
- // - texture for shadow map
- ShaderDataLayout data_layouts[MAX_SHADER_DATA_LAYOUTS];
- u32 data_layouts_count;
-
- bool wireframe;
- bool depth_test;
-} GraphicsPipelineDesc;
-
bool GraphicsPipelineDesc_AddShaderDataLayout(GraphicsPipelineDesc* desc, ShaderDataLayout layout);
typedef struct GPU_RenderpassDesc {
diff --git a/src/render/render_types.h b/src/render/render_types.h
index 16dee1d..bdf9849 100644
--- a/src/render/render_types.h
+++ b/src/render/render_types.h
@@ -10,9 +10,7 @@
#include "ral_types.h"
// --- Handles
-CORE_DEFINE_HANDLE(ModelHandle);
-CORE_DEFINE_HANDLE(MaterialHandle);
-CORE_DEFINE_HANDLE(MeshHandle);
+
#define INVALID_MODEL_HANDLE ((ModelHandle){ .raw = 9999991 })
#define INVALID_MATERIAL_HANDLE ((MaterialHandle){ .raw = 9999992 })
#define INVALID_MESH_HANDLE ((MeshHandle){ .raw = 9999993 })
@@ -24,14 +22,6 @@ typedef enum RenderMode {
RENDER_MODE_COUNT
} RenderMode;
-typedef struct Geometry {
- VertexFormat format;
- Vertex_darray* vertices;
- u32_darray* indices;
- bool has_indices;
- size_t index_count;
-} Geometry;
-
typedef struct u32_opt {
u32 value;
bool has_value;
@@ -42,7 +32,7 @@ typedef struct Mesh {
BufferHandle index_buffer;
Geometry geometry; // NULL means it has been freed CPU-side
MaterialHandle material;
- bool is_skinned; // false = its static
+ bool is_skinned; // false = its static
Armature armature;
bool is_uploaded; // has the data been uploaded to the GPU
} Mesh;