diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-11 23:00:26 +1000 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-08-11 23:00:26 +1000 |
commit | b03bde3d412148cd573f5f14012cdd270f309947 (patch) | |
tree | 848af582079a60787cc5a5f8138e7ca6d508f2ee | |
parent | 48a703e52490cb52fd32e54e3e37f7e70462a267 (diff) |
starting work on immediate mode drawing
41 files changed, 360 insertions, 557 deletions
@@ -1,6 +1,9 @@ # celeritas-core -Celeritas is an engine 'core' written in C that acts as an extendable base layer for creating custom game-specific "engines" (frameworks). It includes helpful wrappers around input handling, cameras, rendering abstractions, and other helpful APIs for making games and binding to other languages' FFIs. +Celeritas is an engine 'core' written in C that acts as an extendable base layer for creating custom game-specific "engines" (frameworks). +Celeritas Core focuses on rendering and platform abstractions, helpful wrappers around input handling, and common components needed by 3D game or interactive applications +such as cameras, collision detection, etc. +Bindings to Rust are WIP and other languages are planned for the future. Higher-level concepts can then be overlaid on top of this core! @@ -10,14 +13,18 @@ Higher-level concepts can then be overlaid on top of this core! All third-party dependencies are licensed under their own license. -## Project Structure +## Features -``` -/bindgen - bindings code generation for other languages -/deps - third-party dependencies -/docs - high-level documentation -/scripts -``` +- Log level based logging +- Arena allocator +- Pool allocator +- Physically based rendering (PBR) +- GLTF loading + +#### RAL (Render Abstraction Layer) +- [x] Buffer/texture creation +- [x] Graphics pipeline creation/deletion +- [ ] Compute shader pipeline creation/deletion/run ## Developing @@ -38,111 +45,6 @@ All third-party dependencies are licensed under their own license. * Build docs static site * `docker run --rm -it -v ${PWD}:/docs squidfunk/mkdocs-material build` -## TODO - -#### Engine -- [ ] Embedded assets - shaders, textures, et al (probably will use C23's `#embed`?) -- [ ] Shader hot-reloading -- [ ] Cross-platform threadpool -- [ ] Frame pacing -- [ ] Logging - - [x] level-based logging - - [ ] log level with module granularity - - [ ] multithreaded buffered logging -- Strings - - [x] custom fat pointer string type - - [ ] utf8 handling -- Maths - - [x] Vector functions - - [x] Mat4 functions - - [ ] SIMD 4x4 multiply - - [ ] Quaternion functions (not fully fleshed out) -- [x] Camera - - [x] Fly camera - - [ ] Swap to quaternion for internal orientation - - [ ] Arcball / Orbit camera -- [ ] Transform gizmo -- [ ] Mesh generation - - [x] Cube - - [x] Plane - - [x] Sphere - - [ ] Cylinder - - [ ] Cone - - [ ] Torus - - [ ] Prism -- Load sponza & bistro scenes -- [ ] Bindings generation (targets: rust, odin, zig, ocaml) (future) - -#### Memory -- [x] Arena allocator - - [x] malloc backed - - [ ] overcommit address-space backed (`VirtualAlloc` & `mmap`) -- [x] Pool allocator (typed) - - [ ] Generational handles -- [ ] SoA hot/cold pool allocator (pool for all entities of same type, split into two structs in SoA so we can have hot ,(`VkHandle`and cold `size`, `format` data separated)) (future) - -#### Scene -- [1/2] Transform hierarchy / Scene tree - - [ ] Transform propagation -- [ ] Asset streaming - -#### Renderer -- [ ] PBR - - [x] Basic implementation using learnopengl - - [ ] Implementation using Google filament as a reference for first in class PBR - - [ ] Handle metallic / roughness being in different channels, combined, or absent -- [ ] Shadows - - [x] Shadowmaps - - [ ] PCF - - [ ] Cascading shadowmaps (CSM) - - [ ] Point light shadows -- [ ] Resizing viewport -- [ ] Debug views (shadow map quad, etc) -- [ ] Cel shading - - [ ] rim light - - [ ] fresnel - - [ ] outline -- [ ] Instanced rendering - - [ ] instanced grass -- [ ] Terrain - - [ ] Heightmaps - - [ ] Chunking + culling - - [ ] Terrain editing (in-game) -- [ ] SSAO - - [ ] depth pre-pass -- [ ] Water - - [ ] water plane -- [ ] Animation - - [x] Joint and keyframe loading - - [ ] Handle multiple animations in one GLTF - - [ ] Animation Blending -- [ ] Frustum culling (CPU) -- [ ] Postprocessing stack - - *TBD* -- [ ] Imposters -- [ ] Volumetric clouds (future) -- [ ] Global illumination (future) -- [ ] GPU-driven rendering (future) - -#### RAL -- [x] Buffer/texture creation -- [x] Graphics pipeline creation/deletion -- [ ] Compute shader pipeline creation/deletion/run -- [ ] Enums for graphics pipeline state (blending, wrapping, etc) - -#### Physics -- [ ] Ground check against heightmap terrain or simple plane -- [ ] Jolt integration -- [ ] In-house Collision detection - -#### UI -*TBD* -- buttons -- text inputs -- colour picker -- file drag-and-drop -- dock-able (sub)windows -- node graph editor #### Logistics @@ -152,4 +54,4 @@ All third-party dependencies are licensed under their own license. ## Questions -- How to expose material properties in the immediate mode UI?
\ No newline at end of file +- How to expose material properties in the immediate mode UI? diff --git a/assets/shaders/immdraw.frag b/assets/shaders/immdraw.frag new file mode 100644 index 0000000..9cb214f --- /dev/null +++ b/assets/shaders/immdraw.frag @@ -0,0 +1,9 @@ +#version 410 core + +out vec4 FragColor; + +in vec4 aColour; + +void main() { + FragColor = aColour; +} diff --git a/assets/shaders/immdraw.vert b/assets/shaders/immdraw.vert new file mode 100644 index 0000000..ee9e7ca --- /dev/null +++ b/assets/shaders/immdraw.vert @@ -0,0 +1,23 @@ +#version 410 core + +layout(location = 0) in vec3 inPosition; +layout(location = 1) in vec3 inNormal; +layout(location = 2) in vec2 inTexCoords; + +uniform Camera { + mat4 view; + mat4 proj; + vec4 viewPos; +} cam; + +uniform ImmUniforms { + mat4 model; + vec4 colour; +} imm; + +out vec4 aColour; + +void main() { + aColour = imm.colour; + gl_Position = cam.proj * cam.view * imm.model * vec4(inPosition, 1.0); +} diff --git a/bindgen/rust/celeritas-sys/build.rs b/bindgen/rust/celeritas-sys/build.rs index b356bb0..de12094 100644 --- a/bindgen/rust/celeritas-sys/build.rs +++ b/bindgen/rust/celeritas-sys/build.rs @@ -44,7 +44,7 @@ fn main() { // println!("cargo:rustc-link-search=../../build/windows/x64/debug"); let static_lib_path = - "/Users/josh/code/CodenameVentus/deps/celeritas-core/build/macosx/arm64/release" + "/Users/josh/code/CodenameVentus/deps/celeritas-core/build/macosx/arm64/debug" .to_string(); // let static_lib_path = std::env::var("CELERITAS_CORE_LIB") // .unwrap_or("../../../build/macosx/arm64/debug".to_string()); diff --git a/examples/game_demo/game_demo.c b/examples/game_demo/game_demo.c index bc7e0f6..22af64e 100644 --- a/examples/game_demo/game_demo.c +++ b/examples/game_demo/game_demo.c @@ -7,10 +7,12 @@ #include "camera.h" #include "core.h" #include "grid.h" +#include "immdraw.h" #include "input.h" #include "keys.h" #include "loaders.h" #include "maths.h" +#include "maths_types.h" #include "pbr.h" #include "primitives.h" #include "ral_types.h" @@ -98,21 +100,23 @@ int main() { // BEGIN Draw calls RenderEnt_darray_clear(render_entities); // we re-extract every frame - Quat rot = quat_from_axis_angle(VEC3_X, -HALF_PI, true); + // Quat rot = quat_from_axis_angle(VEC3_X, -HALF_PI, true); // Mat4 affine = mat4_rotation(rot); Mat4 affine = mat4_ident(); ModelExtractRenderEnts(render_entities, cube_handle, affine, REND_ENT_CASTS_SHADOWS); // Shadow_Run(entities, entity_count); - - if (draw_debug) { - // draw the player model with shadows - Render_RenderEntities(render_entities->data, render_entities->len); - // Render_DrawTerrain(); - Skybox_Draw(&skybox, cam); - } else { - Shadow_DrawDebugQuad(); - } + Quat rot = quat_from_axis_angle(VEC3_X, HALF_PI, true); + Immdraw_Sphere(transform_create(VEC3_ZERO, rot, 1.0), 1.0, vec4(1.0, 0.0, 0.0, 1.0), false); + + // if (draw_debug) { + // // draw the player model with shadows + // Render_RenderEntities(render_entities->data, render_entities->len); + // // Render_DrawTerrain(); + // Skybox_Draw(&skybox, cam); + // } else { + // Shadow_DrawDebugQuad(); + // } // Terrain_Draw(terrain); // Grid_Draw(); diff --git a/examples/skinned_animation/ex_skinned_animation.c b/examples/skinned_animation/ex_skinned_animation.c index c31e93c..7704b99 100644 --- a/examples/skinned_animation/ex_skinned_animation.c +++ b/examples/skinned_animation/ex_skinned_animation.c @@ -1,122 +1,77 @@ #include <assert.h> #include <glfw3.h> -#include "../example_scene.h" -#include "animation.h" #include "camera.h" #include "core.h" -#include "input.h" -#include "keys.h" +#include "loaders.h" #include "log.h" #include "maths.h" #include "maths_types.h" -#include "primitives.h" -#include "render.h" -#include "render_backend.h" #include "render_types.h" -typedef struct game_state { - camera camera; - vec3 camera_euler; - bool first_mouse_update; // so the camera doesnt lurch when you run the first - // process_camera_rotation -} game_state; - -void update_camera_rotation(input_state* input, game_state* game, camera* cam); - int main() { double currentFrame = glfwGetTime(); double lastFrame = currentFrame; double deltaTime; - core* core = core_bringup(); - - model_handle handle = - model_load_gltf(core, "assets/models/gltf/SimpleSkin/glTF/SimpleSkin.gltf", false); + Core_Bringup("Skinned Animation", NULL); - model* simple_skin = &core->models->data[handle.raw]; + ModelHandle handle = ModelLoad_gltf("assets/models/gltf/SimpleSkin/glTF/SimpleSkin.gltf", false); + Model* simple_skin = MODEL_GET(handle); // Okay, right here we've loaded the model. let's assert some facts - assert(simple_skin->animations->len == 1); - assert(simple_skin->animations->data[0].rotation != NULL); - assert(simple_skin->animations->data[0].translation == NULL); - assert(simple_skin->animations->data[0].scale == NULL); + // assert(simple_skin->animations->len == 1); + // assert(simple_skin->animations->data[0].rotation != NULL); + // assert(simple_skin->animations->data[0].translation == NULL); + // assert(simple_skin->animations->data[0].scale == NULL); - mesh* m = &simple_skin->meshes->data[0]; - assert(m->is_skinned); - assert(m->bones->len == 2); // 1 root and 1 extra joint + // mesh* m = &simple_skin->meshes->data[0]; + // assert(m->is_skinned); + // assert(m->bones->len == 2); // 1 root and 1 extra joint // assert(false); - model_upload_meshes(&core->renderer, simple_skin); + // model_upload_meshes(&core->renderer, simple_skin); - scene our_scene = make_default_scene(); + // scene our_scene = make_default_scene(); - vec3 cam_pos = vec3_create(0, 5, -8); - game_state game = { - .camera = camera_create(cam_pos, vec3_negate(cam_pos), VEC3_Y, deg_to_rad(45.0)), - .camera_euler = vec3_create(90, 0, 0), - .first_mouse_update = true, - }; - - print_vec3(game.camera.front); + Vec3 cam_pos = vec3_create(0, 5, -8); + Camera camera = + Camera_Create(cam_pos, vec3_normalise(vec3_negate(cam_pos)), VEC3_Y, deg_to_rad(45.0)); // Main loop const f32 camera_lateral_speed = 0.2; const f32 camera_zoom_speed = 0.10; // animation - animation_clip track = simple_skin->animations->data[0]; - f64 total_time = 0.0; + // animation_clip track = simple_skin->animations->data[0]; + // f64 total_time = 0.0; - while (!should_exit(core)) { - input_update(&core->input); + while (!ShouldExit()) { + Frame_Begin(); currentFrame = glfwGetTime(); deltaTime = currentFrame - lastFrame; lastFrame = currentFrame; - total_time += deltaTime; + // total_time += deltaTime; // printf("delta time %f\n", deltaTime); - f64 t = fmod(total_time, track.rotation->max); + // f64 t = fmod(total_time, track.rotation->max); // INFO("Total time: %f", t); - vec3 translation = VEC3_ZERO; - if (key_is_pressed(KEYCODE_W)) { - translation = vec3_mult(game.camera.front, camera_zoom_speed); - } else if (key_is_pressed(KEYCODE_KEY_UP)) { - translation = vec3_mult(game.camera.up, camera_lateral_speed); - } else if (key_is_pressed(KEYCODE_KEY_DOWN)) { - translation = vec3_mult(game.camera.up, -camera_lateral_speed); - } else if (key_is_pressed(KEYCODE_S) || key_is_pressed(KEYCODE_KEY_DOWN)) { - translation = vec3_mult(game.camera.front, -camera_zoom_speed); - } else if (key_is_pressed(KEYCODE_A) || key_is_pressed(KEYCODE_KEY_LEFT)) { - vec3 lateral = vec3_normalise(vec3_cross(game.camera.front, game.camera.up)); - translation = vec3_mult(lateral, -camera_lateral_speed); - } else if (key_is_pressed(KEYCODE_D) || key_is_pressed(KEYCODE_KEY_RIGHT)) { - vec3 lateral = vec3_normalise(vec3_cross(game.camera.front, game.camera.up)); - translation = vec3_mult(lateral, camera_lateral_speed); - } - game.camera.position = vec3_add(game.camera.position, translation); - - render_frame_begin(&core->renderer); - // bone rotation - quat rot = animation_sample(track.rotation, t).rotation; + // Quat rot = animation_sample(track.rotation, t).rotation; - m->bones->data[1].transform_components.rotation = rot; + // m->bones->data[1].transform_components.rotation = rot; // quat rot = quat_ident(); - transform tf = transform_create(VEC3_ZERO, quat_ident(), 1.0); + Transform tf = transform_create(VEC3_ZERO, quat_ident(), 1.0); - draw_skinned_model(&core->renderer, &game.camera, simple_skin, tf, &our_scene); + // draw_skinned_model(&core->renderer, &game.camera, simple_skin, tf, &our_scene); - render_frame_end(&core->renderer); + Frame_End(); } INFO("Shutting down"); - model_destroy(simple_skin); - - core_shutdown(core); return 0; } diff --git a/src/animation.h b/src/animation.h index 66277e9..343746a 100644 --- a/src/animation.h +++ b/src/animation.h @@ -4,7 +4,11 @@ #include "defines.h" #include "maths_types.h" -typedef enum Interpolation { INTERPOLATION_LINEAR, INTERPOLATION_COUNT } Interpolation; +typedef enum Interpolation { + INTERPOLATION_STEP, + INTERPOLATION_LINEAR, + INTERPOLATION_CUBIC, /** @brief Cubic spline interpolation */ + INTERPOLATION_COUNT } Interpolation; typedef enum KeyframeKind { KEYFRAME_ROTATION, diff --git a/src/collision.h b/src/collision.h new file mode 100644 index 0000000..4ac9ec3 --- /dev/null +++ b/src/collision.h @@ -0,0 +1,20 @@ +#pragma once +#include "geometry.h" + +enum ColliderType { + CuboidCollider, + SphereCollider, +}; + +/** @brief generic collider structure */ +typedef struct Collider { + u64 id; // ? Replace with handle? + enum ColliderType shape; + union collider_data { + Cuboid cuboid; + Sphere sphere; + } geometry; + Transform transform; + u8 layer; + bool on_ground; +} Collider; diff --git a/src/core/core.c b/src/core/core.c index 7d209d5..64f59f3 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -9,7 +9,6 @@ #include "mem.h" #include "render.h" #include "render_types.h" -#include "scene.h" // These are only the initial window dimensions #define SCR_WIDTH 1000 @@ -30,7 +29,9 @@ void Core_Bringup(const char* window_name, struct GLFWwindow* optional_window) { .clear_colour = (Vec3){ .08, .08, .1 } }; g_core.renderer = malloc(Renderer_GetMemReqs()); - // initialise all subsystems + + // Initialise all subsystems + // renderer config, renderer ptr, ptr to store a window, and optional preexisting glfw window if (!Renderer_Init(conf, g_core.renderer, &g_core.window, optional_window)) { // FATAL("Failed to start renderer"); @@ -52,9 +53,6 @@ void Core_Bringup(const char* window_name, struct GLFWwindow* optional_window) { Model_pool model_pool = Model_pool_create(&model_arena, 256, sizeof(Model)); g_core.models = model_pool; INFO("Created model pool allocator"); - - // INFO("Creating default scene"); - // scene_init(&g_core.default_scene); } void Core_Shutdown() { @@ -78,8 +76,6 @@ 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/core/core.h b/src/core/core.h index 4e7ff03..be44b8c 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -3,7 +3,6 @@ #include "input.h" #include "mem.h" #include "render_types.h" -#include "scene.h" #include "screenspace.h" #include "terrain.h" #include "text.h" diff --git a/src/maths/geometry.h b/src/maths/geometry.h index 0df80fc..532651c 100644 --- a/src/maths/geometry.h +++ b/src/maths/geometry.h @@ -19,13 +19,13 @@ // vec3 normal; // } plane; -// typedef struct cuboid { -// vec3 half_extents; -// } cuboid; +typedef struct Cuboid { + Vec3 half_extents; +} Cuboid; -// typedef struct sphere { -// f32 radius; -// } sphere; +typedef struct Sphere { + f32 radius; +} Sphere; // typedef struct cylinder { // f32 radius; diff --git a/src/maths/primitives.c b/src/maths/primitives.c index 4a4d55f..d353d33 100644 --- a/src/maths/primitives.c +++ b/src/maths/primitives.c @@ -35,22 +35,25 @@ Geometry Geo_CreatePlane(f32x2 extents) { vert_pos[i].x *= extents.x; vert_pos[i].z *= extents.y; } - VERT_3D(vertices, vert_pos[0], VEC3_Y, vec2(0, 0)); - VERT_3D(vertices, vert_pos[1], VEC3_Y, vec2(1, 0)); - VERT_3D(vertices, vert_pos[2], VEC3_Y, vec2(0, 1)); - VERT_3D(vertices, vert_pos[3], VEC3_Y, vec2(1, 1)); + VERT_3D(vertices, vert_pos[0], VEC3_Y, vec2(0, 0)); // back left + VERT_3D(vertices, vert_pos[1], VEC3_Y, vec2(1, 0)); // back right + VERT_3D(vertices, vert_pos[2], VEC3_Y, vec2(0, 1)); // front left + VERT_3D(vertices, vert_pos[3], VEC3_Y, vec2(1, 1)); // front right - /* push_triangle(indices, 0, 1, 2); */ - /* push_triangle(indices, 2, 1, 3); */ - push_triangle(indices, 2, 1, 0); - push_triangle(indices, 3, 1, 2); + push_triangle(indices, 0, 1, 2); + push_triangle(indices, 2, 1, 3); + // push_triangle(indices, 2, 1, 0); + // push_triangle(indices, 3, 2, 1); + + for (int i = 0; i < 4; i++) { + printf("Vertex %d: (%f, %f, %f)\n", i, vert_pos[i].x, vert_pos[i].y, vert_pos[i].z); + } Geometry geo = { .format = VERTEX_STATIC_3D, .vertices = vertices, .has_indices = true, .index_count = indices->len, .indices = indices }; - // .colour = (rgba){ 0, 0, 0, 1 } }; return geo; } @@ -239,5 +242,6 @@ Geometry Geo_CreateUVsphere(f32 radius, u32 north_south_lines, u32 east_west_lin .index_count = indices->len, .indices = indices, }; + return geo; } diff --git a/src/physics/physics.h b/src/physics.h index e0e3b89..e0e3b89 100644 --- a/src/physics/physics.h +++ b/src/physics.h diff --git a/src/physics/broadphase.h b/src/physics/broadphase.h deleted file mode 100644 index 8b49716..0000000 --- a/src/physics/broadphase.h +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @file broadphase.h - * @author your name (you@domain.com) - * @brief - * @version 0.1 - * @date 2024-05-12 - * - * @copyright Copyright (c) 2024 - * - */
\ No newline at end of file diff --git a/src/physics/collision.h b/src/physics/collision.h deleted file mode 100644 index cca6042..0000000 --- a/src/physics/collision.h +++ /dev/null @@ -1,30 +0,0 @@ -/** - * @file collision.h - * @author your name (you@domain.com) - * @brief - * @version 0.1 - * @date 2024-05-12 - * - * @copyright Copyright (c) 2024 - * - */ -#pragma once -#include "geometry.h" - -enum collider_type { - cuboid_collider, - sphere_collider, -}; - -/** @brief generic collider structure */ -typedef struct physics_collider { - u64 id; // ? Replace with handle? - enum collider_type shape; - union collider_data { - cuboid cuboid; - sphere sphere; - } geometry; - transform transform; - u8 layer; - bool on_ground; -} physics_collider;
\ No newline at end of file diff --git a/src/physics/narrowphase.h b/src/physics/narrowphase.h deleted file mode 100644 index 2368c49..0000000 --- a/src/physics/narrowphase.h +++ /dev/null @@ -1,10 +0,0 @@ -/** - * @file narrowphase.h - * @author your name (you@domain.com) - * @brief - * @version 0.1 - * @date 2024-05-12 - * - * @copyright Copyright (c) 2024 - * - */
\ No newline at end of file diff --git a/src/physics/physics.c b/src/physics/physics.c deleted file mode 100644 index 299c0c1..0000000 --- a/src/physics/physics.c +++ /dev/null @@ -1 +0,0 @@ -#include "physics.h"
\ No newline at end of file diff --git a/src/platform/mutex.c b/src/platform/mutex.c deleted file mode 100644 index 2aeb825..0000000 --- a/src/platform/mutex.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "mutex.h" - -#if defined(CEL_PLATFORM_LINUX) || defined(CEL_PLATFORM_MAC) -// TODO: implement in terms of pthreads -#endif - -#if defined(CEL_PLATFORM_WINDOWS) -// TODO: implement using win32 api -#endif
\ No newline at end of file diff --git a/src/platform/mutex.h b/src/platform/mutex.h deleted file mode 100644 index a0a4208..0000000 --- a/src/platform/mutex.h +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @file mutex.h - * @author your name (you@domain.com) - * @brief - * @version 0.1 - * @date 2024-04-27 - * - * @copyright Copyright (c) 2024 - * - */ -#include <stdbool.h> - -typedef struct cel_mutex cel_mutex; - -cel_mutex mutex_create(); - -void mutex_destroy(cel_mutex* mutex); - -/** @brief Blocks until the mutex can be acquired. if returns false then an error occurred and can - * be checked (TODO) */ -bool mutex_lock(cel_mutex* mutex); - -/** @brief Tries to acquire the mutex like `mutex_lock` but returns immediately if the mutex has - * already been locked */ -bool mutex_try_lock(cel_mutex* mutex); - -/** @brief Releases a mutex. If it is already unlocked then does nothing */ -void mutex_unlock(cel_mutex* mutex);
\ No newline at end of file diff --git a/src/platform/path.c b/src/platform/path.c deleted file mode 100644 index f43d954..0000000 --- a/src/platform/path.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "path.h" - -#include <stdlib.h> -#include <string.h> -#include "mem.h" -#include "str.h" - -#if defined(CEL_PLATFORM_LINUX) || defined(CEL_PLATFORM_MAC) -#include <libgen.h> -path_opt path_parent(arena* a, const char* path) { - // Duplicate the string because dirname doesnt like const literals - char* path_copy = arena_alloc(a, strlen(path) + 1); - strcpy(path_copy, path); - char* path_dirname = dirname(path_copy); - return (path_opt){ .path = Str8_cstr_view(path_dirname), .has_value = true }; -} -#endif -#ifdef CEL_PLATFORM_WINDOWS -#include <shlwapi.h> -#include <windows.h> -#pragma comment(lib, "Shlwapi.lib") - -path_opt path_parent(arena* a, const char* path) { - // Duplicate the string because PathRemoveFileSpec mutates in-place - size_t len = strlen(path) + 1; - char* path_copy = arena_alloc(a, len); - strcpy_s(path_copy, len, path); - - if (PathRemoveFileSpecA(path_copy)) { - return (path_opt){ .path = Str8_cstr_view(path_copy), .has_value = true }; - } else { - return (path_opt){ .has_value = false }; - } -} -#endif diff --git a/src/platform/path.h b/src/platform/path.h deleted file mode 100644 index ce53339..0000000 --- a/src/platform/path.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @file path.h - * @brief - * @date 2024-03-11 - * @copyright Copyright (c) 2024 - */ -#pragma once - -#include "str.h" - -typedef struct path_opt { - Str8 path; - bool has_value; -} path_opt; - -path_opt path_parent(arena* a, const char* path); // TODO: convert to using str8 diff --git a/src/platform/platform.h b/src/platform/platform.h new file mode 100644 index 0000000..c2be630 --- /dev/null +++ b/src/platform/platform.h @@ -0,0 +1,37 @@ +#pragma once + +#include "defines.h" +#include "str.h" + +// -- Paths +typedef struct path_opt { + Str8 path; + bool has_value; +} path_opt; + +// TODO: convert to using str8 +// TODO: use uppercase code style +path_opt path_parent(arena* a, const char* path); + +// --- Threads +typedef struct CelThread CelThread; + +CelThread Thread_Create(); +void Thread_Destroy(CelThread* thread); + +// --- Mutexes +typedef struct CelMutex CelMutex; + +CelMutex Mutex_Create(); +void Mutex_Destroy(CelMutex* mutex); + +/** @brief Blocks until the mutex can be acquired. if returns false then an error occurred and can + * be checked (TODO) */ +bool Mutex_Lock(CelMutex* mutex); + +/** @brief Tries to acquire the mutex like `mutex_lock` but returns immediately if the mutex has + * already been locked */ +bool Mutex_TryLock(CelMutex* mutex); + +/** @brief Releases a mutex. If it is already unlocked then does nothing */ +void Mutex_Unlock(CelMutex* mutex); diff --git a/src/platform/platform_unix.c b/src/platform/platform_unix.c new file mode 100644 index 0000000..86ac170 --- /dev/null +++ b/src/platform/platform_unix.c @@ -0,0 +1,16 @@ +#include "platform.h" + +#if defined(CEL_PLATFORM_LINUX) || defined(CEL_PLATFORM_MAC) + +#include <libgen.h> +#include <string.h> + +path_opt path_parent(arena* a, const char* path) { + // Duplicate the string because dirname doesnt like const literals + char* path_copy = arena_alloc(a, strlen(path) + 1); + strcpy(path_copy, path); + char* path_dirname = dirname(path_copy); + return (path_opt){ .path = Str8_cstr_view(path_dirname), .has_value = true }; +} + +#endif diff --git a/src/platform/platform_windows.c b/src/platform/platform_windows.c new file mode 100644 index 0000000..21ef359 --- /dev/null +++ b/src/platform/platform_windows.c @@ -0,0 +1,22 @@ +#include "platform.h" + +#if defined(CEL_PLATFORM_WINDOWS) + +#include <shlwapi.h> +#include <windows.h> +#pragma comment(lib, "Shlwapi.lib") + +path_opt path_parent(arena* a, const char* path) { + // Duplicate the string because PathRemoveFileSpec mutates in-place + size_t len = strlen(path) + 1; + char* path_copy = arena_alloc(a, len); + strcpy_s(path_copy, len, path); + + if (PathRemoveFileSpecA(path_copy)) { + return (path_opt){ .path = Str8_cstr_view(path_copy), .has_value = true }; + } else { + return (path_opt){ .has_value = false }; + } +} + +#endif diff --git a/src/platform/thread.c b/src/platform/thread.c deleted file mode 100644 index e69de29..0000000 --- a/src/platform/thread.c +++ /dev/null diff --git a/src/platform/thread.h b/src/platform/thread.h deleted file mode 100644 index af07d3f..0000000 --- a/src/platform/thread.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * @file thread.h - * @author your name (you@domain.com) - * @brief - * @version 0.1 - * @date 2024-04-27 - * - * @copyright Copyright (c) 2024 - * - */ - -typedef struct cel_thread cel_thread; - -cel_thread thread_create(); -void thread_destroy(cel_thread* thread); - -// join
\ No newline at end of file diff --git a/src/ral/backends/opengl/backend_opengl.c b/src/ral/backends/opengl/backend_opengl.c index 7862a81..3822220 100644 --- a/src/ral/backends/opengl/backend_opengl.c +++ b/src/ral/backends/opengl/backend_opengl.c @@ -57,8 +57,7 @@ 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; } @@ -430,7 +429,7 @@ PUB void GPU_WriteTextureRegion(GPU_CmdEncoder* encoder, TextureHandle dst, u32 bool GPU_Backend_BeginFrame() { glViewport(0, 0, context.swapchain.dimensions.x * 2, context.swapchain.dimensions.y * 2); - glClearColor(0.8f, 0.8f, 0.8f, 1.0f); + glClearColor(0.1f, 0.1f, 0.1f, 1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); return true; } diff --git a/src/ral/backends/opengl/opengl_helpers.h b/src/ral/backends/opengl/opengl_helpers.h index 0450c74..8a78de5 100644 --- a/src/ral/backends/opengl/opengl_helpers.h +++ b/src/ral/backends/opengl/opengl_helpers.h @@ -57,7 +57,7 @@ static u32 opengl_bindcreate_vao(GPU_Buffer* buf, VertexDescription desc) { // Attributes u32 attr_count = desc.attributes_count; - printf("N attributes %d\n", attr_count); + // printf("N attributes %d\n", attr_count); u64 offset = 0; size_t vertex_size = desc.use_full_vertex_size ? sizeof(Vertex) : VertexDesc_CalcStride(&desc); for (u32 i = 0; i < desc.attributes_count; i++) { @@ -67,7 +67,7 @@ static u32 opengl_bindcreate_vao(GPU_Buffer* buf, VertexDescription desc) { desc.attr_names[i]); glEnableVertexAttribArray(i); // nth index size_t this_offset = VertexAttribSize(desc.attributes[i]); - printf("offset total %lld this attr %zu\n", offset, this_offset); + // printf("offset total %lld this attr %zu\n", offset, this_offset); offset += this_offset; } glBindBuffer(GL_ARRAY_BUFFER, 0); diff --git a/src/render/immdraw.c b/src/render/immdraw.c index c711b0c..dfe189a 100644 --- a/src/render/immdraw.c +++ b/src/render/immdraw.c @@ -1,5 +1,8 @@ #include "immdraw.h" +#include "core.h" +#include "file.h" #include "log.h" +#include "maths.h" #include "primitives.h" #include "ral_common.h" #include "ral_impl.h" @@ -9,20 +12,91 @@ void Immdraw_Init(Immdraw_Storage* storage) { INFO("Immediate drawing initialisation"); - // meshes - // Geometry sphere_geo = Geo_CreateUVsphere(1.0, 8, 8); - // storage->sphere = Mesh_Create(&sphere_geo, false); - // pipeline / material + // Meshes + Geometry sphere_geo = Geo_CreateUVsphere(1.0, 8, 8); + storage->sphere = Mesh_Create(&sphere_geo, false); + + Geometry cube_geo = Geo_CreateCuboid(f32x3(2.0, 2.0, 2.0)); + storage->cube = Mesh_Create(&cube_geo, false); + + Geometry plane_geo = Geo_CreatePlane(f32x2(2.0, 2.0)); + storage->plane = Mesh_Create(&plane_geo, false); + + // Pipeline / material + VertexDescription vertex_desc = { + .debug_label = "Immdraw Vertex", + .use_full_vertex_size = true, + }; + VertexDesc_AddAttr(&vertex_desc, "position", ATTR_F32x3); + VertexDesc_AddAttr(&vertex_desc, "normal", ATTR_F32x3); + + arena scratch = arena_create(malloc(1024 * 1024), 1024 * 1024); + Str8 vert_path = str8("assets/shaders/immdraw.vert"); + Str8 frag_path = str8("assets/shaders/immdraw.frag"); + str8_opt vertex_shader = str8_from_file(&scratch, vert_path); + str8_opt fragment_shader = str8_from_file(&scratch, frag_path); + if (!vertex_shader.has_value || !fragment_shader.has_value) { + ERROR_EXIT("Failed to load shaders from disk"); + } + ShaderDataLayout camera_data = Binding_Camera_GetLayout(NULL); + ShaderDataLayout imm_uniform_data = ImmediateUniforms_GetLayout(NULL); + GraphicsPipelineDesc pipeline_desc = { .debug_name = "Immediate Draw Pipeline", - .data_layouts = { camera_data }, - .data_layouts_count = 1, - + .vertex_desc = static_3d_vertex_description(), + .data_layouts = { camera_data, imm_uniform_data }, + .data_layouts_count = 2, + .vs = { .debug_name = "Immdraw Vertex Shader", + .filepath = vert_path, + .code = vertex_shader.contents }, + .fs = { .debug_name = "Immdraw Fragment Shader", + .filepath = frag_path, + .code = fragment_shader.contents }, + .depth_test = true, + .wireframe = false, }; - // storage->colour_pipeline = GPU_GraphicsPipeline_Create(pipeline_desc, - // GPU_GetDefaultRenderpass()); + GPU_Renderpass* rpass = + GPU_Renderpass_Create((GPU_RenderpassDesc){ .default_framebuffer = true }); + storage->colour_pipeline = GPU_GraphicsPipeline_Create(pipeline_desc, rpass); } -void Immdraw_Sphere(Transform tf, f32 size, Vec4 colour, bool wireframe) {}
\ No newline at end of file +void Immdraw_Shutdown(Immdraw_Storage* storage) { + GraphicsPipeline_Destroy(storage->colour_pipeline); +} + +void Immdraw_Sphere(Transform tf, f32 size, Vec4 colour, bool wireframe) { + INFO("Draw sphere"); + Immdraw_Storage* imm = Render_GetImmdrawStorage(); + GPU_CmdEncoder* enc = GPU_GetDefaultEncoder(); + + // begin renderpass + GPU_CmdEncoder_BeginRender(enc, imm->colour_pipeline->renderpass); + // bind pipeline + GPU_EncodeBindPipeline(enc, imm->colour_pipeline); + + // update uniforms + ImmediateUniforms uniforms = { + .model = transform_to_mat(&tf), + .colour = colour, + }; + Mat4 view, proj; + u32x2 dimensions = GPU_Swapchain_GetDimensions(); + RenderScene* scene = Render_GetScene(); + Camera_ViewProj(&scene->camera, (f32)dimensions.x, (f32)dimensions.y, &view, &proj); + Binding_Camera camera_data = { .view = view, + .projection = proj, + .viewPos = vec4(scene->camera.position.x, scene->camera.position.y, + scene->camera.position.z, 1.0) }; + GPU_EncodeBindShaderData(enc, 0, Binding_Camera_GetLayout(&camera_data)); + GPU_EncodeBindShaderData(enc, 1, ImmediateUniforms_GetLayout(&uniforms)); + + // draw call + GPU_EncodeSetVertexBuffer(enc, imm->plane.vertex_buffer); + GPU_EncodeSetIndexBuffer(enc, imm->plane.index_buffer); + GPU_EncodeDrawIndexed(enc, imm->plane.geometry.index_count); + + // end renderpass + GPU_CmdEncoder_EndRender(enc); +} diff --git a/src/render/immdraw.h b/src/render/immdraw.h index 0d58375..e635531 100644 --- a/src/render/immdraw.h +++ b/src/render/immdraw.h @@ -6,15 +6,21 @@ #include "defines.h" #include "maths_types.h" #include "ral_impl.h" +#include "ral_types.h" #include "render_types.h" typedef struct Immdraw_Storage { Mesh plane; Mesh cube; Mesh sphere; - GPU_Pipeline* colour_pipeline; + GPU_Pipeline* colour_pipeline; /** @brief Pipeline for drawing geometry that has vertex colours */ } Immdraw_Storage; +typedef struct ImmediateUniforms { + Mat4 model; + Vec4 colour; +} ImmediateUniforms; + // --- Public API PUB void Immdraw_Init(Immdraw_Storage* storage); @@ -24,4 +30,25 @@ PUB void Immdraw_Shutdown(Immdraw_Storage* storage); PUB void Immdraw_Plane(Transform tf, Vec4 colour, bool wireframe); PUB void Immdraw_Cuboid(Transform tf, Vec4 colour, bool wireframe); PUB void Immdraw_Sphere(Transform tf, f32 size, Vec4 colour, bool wireframe); + PUB void Immdraw_TransformGizmo(Transform tf, f32 size); + +// --- Internal + +static ShaderDataLayout ImmediateUniforms_GetLayout(void* data) { + ImmediateUniforms* d = (ImmediateUniforms*)data; + bool has_data = data != NULL; + + ShaderBinding b1 = { + .label = "ImmUniforms", + .kind = BINDING_BYTES, + // .vis = VISIBILITY_VERTEX, + .data.bytes.size = sizeof(ImmediateUniforms) + }; + + if (has_data) { + b1.data.bytes.data = d; + } + + return (ShaderDataLayout) {.bindings = { b1 }, .binding_count = 1}; +} diff --git a/src/render/render.c b/src/render/render.c index bad245a..bf8ac36 100644 --- a/src/render/render.c +++ b/src/render/render.c @@ -100,22 +100,12 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window } } - // #if defined(CEL_REND_BACKEND_OPENGL) - // glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); - // glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); - // glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - // glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); - // #elif defined(CEL_REND_BACKEND_VULKAN) - // glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); - // #endif - ren->window = window; *out_window = window; glfwMakeContextCurrent(ren->window); - // FIXME - // DEBUG("Set up GLFW window callbacks"); + DEBUG("Set up GLFW window callbacks"); glfwSetWindowSizeCallback(window, Render_WindowSizeChanged); // set the RAL backend up @@ -143,8 +133,8 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window ren->terrain = calloc(1, sizeof(Terrain_Storage)); Terrain_Init(ren->terrain); - ren->grid = calloc(1, sizeof(Grid_Storage)); - Grid_Init(ren->grid); + // ren->grid = calloc(1, sizeof(Grid_Storage)); + // Grid_Init(ren->grid); ren->immediate = calloc(1, sizeof(Immdraw_Storage)); Immdraw_Init(ren->immediate); @@ -329,6 +319,11 @@ Grid_Storage* Render_GetGridStorage() { return ren->grid; } +Immdraw_Storage* Render_GetImmdrawStorage() { + Renderer* ren = Core_GetRenderer(&g_core); + return ren->immediate; +} + TextureHandle Render_GetWhiteTexture() { Renderer* ren = Core_GetRenderer(&g_core); return ren->white_1x1; diff --git a/src/render/render.h b/src/render/render.h index 5dc3853..785c140 100644 --- a/src/render/render.h +++ b/src/render/render.h @@ -6,6 +6,7 @@ #include "camera.h" #include "defines.h" #include "grid.h" +#include "immdraw.h" #include "maths_types.h" #include "ral_types.h" #include "render_types.h" @@ -101,6 +102,7 @@ RenderScene* Render_GetScene(); Shadow_Storage* Render_GetShadowStorage(); Terrain_Storage* Render_GetTerrainStorage(); Grid_Storage* Render_GetGridStorage(); +Immdraw_Storage* Render_GetImmdrawStorage(); TextureHandle Render_GetWhiteTexture(); arena* Render_GetFrameArena(); Mesh_pool* Render_GetMeshPool(); diff --git a/src/render/render_types.h b/src/render/render_types.h index 5fdca8a..924777a 100644 --- a/src/render/render_types.h +++ b/src/render/render_types.h @@ -41,8 +41,8 @@ typedef struct Mesh { BufferHandle vertex_buffer; BufferHandle index_buffer; Geometry geometry; // NULL means it has been freed CPU-side - // i32 material_index; // -1 => no material MaterialHandle material; + bool is_skinned; // false = its static bool is_uploaded; // has the data been uploaded to the GPU } Mesh; #ifndef TYPED_MESH_CONTAINERS diff --git a/src/resources/gltf.c b/src/resources/gltf.c index 01291ea..aa4fba5 100644 --- a/src/resources/gltf.c +++ b/src/resources/gltf.c @@ -11,8 +11,8 @@ #include "maths.h" #include "maths_types.h" #include "mem.h" -#include "path.h" #include "pbr.h" +#include "platform.h" #include "ral_types.h" #include "render.h" #include "render_types.h" @@ -149,9 +149,9 @@ bool model_load_gltf_str(const char *file_string, const char *filepath, Str8 rel Material_darray *tmp_materials = Material_darray_new(1); Mesh_darray *tmp_meshes = Mesh_darray_new(1); u32_darray *tmp_material_indexes = u32_darray_new(1); + Joint_darray *tmp_joints = Joint_darray_new(256); // FIXME - // joint_darray *tmp_joints = joint_darray_new(256); // vertex_bone_data_darray *tmp_vertex_bone_data = vertex_bone_data_darray_new(1000); cgltf_options options = { 0 }; @@ -306,13 +306,15 @@ bool model_load_gltf_str(const char *file_string, const char *filepath, Str8 rel // Store vertices printf("Positions %d Normals %d UVs %d\n", tmp_positions->len, tmp_normals->len, tmp_uvs->len); - assert(tmp_positions->len == tmp_normals->len); - assert(tmp_normals->len == tmp_uvs->len); + // assert(tmp_positions->len == tmp_normals->len); + // assert(tmp_normals->len == tmp_uvs->len); + bool has_normals = tmp_normals->len > 0; + bool has_uvs = tmp_uvs->len > 0; for (u32 v_i = 0; v_i < tmp_positions->len; v_i++) { Vertex v = { .static_3d = { .position = tmp_positions->data[v_i], - .normal = tmp_normals->data[v_i], - .tex_coords = tmp_uvs->data[v_i], + .normal = has_normals ? tmp_normals->data[v_i] : VEC3_ZERO, + .tex_coords = has_uvs ? tmp_uvs->data[v_i] : vec2_create(0., 0.), } }; Vertex_darray_push(geo_vertices, v); } diff --git a/src/resources/obj.c b/src/resources/obj.c index e5b2fc9..e02cb9a 100644 --- a/src/resources/obj.c +++ b/src/resources/obj.c @@ -16,9 +16,8 @@ #include "log.h" #include "maths.h" #include "mem.h" -#include "path.h" +#include "platform.h" #include "render.h" -// #include "render_backend.h" #include "render_types.h" #include "str.h" diff --git a/src/scene.c b/src/scene.c deleted file mode 100644 index f6f5fb7..0000000 --- a/src/scene.c +++ /dev/null @@ -1,57 +0,0 @@ -#include "scene.h" -#include "camera.h" -#include "core.h" -#include "log.h" -#include "maths.h" -#include "render_types.h" - -extern Core g_core; - -// void scene_init(scene *s) { -// memset(s, 0, sizeof(scene)); -// s->renderables = render_entity_darray_new(10); -// // default camera position - moved slightly along Z axis looking at 0,0,0 -// Vec3 cam_pos = vec3_create(0, 0, -5); -// s->camera = Camera_Create(cam_pos, vec3_negate(cam_pos), VEC3_Y, deg_to_rad(45.0)); -// } -// void scene_free(scene *s) { render_entity_darray_free(s->renderables); } - -// void scene_set_dir_light(directional_light light) { g_core.default_scene.dir_light = light; } -// void scene_add_point_light(point_light light) { -// scene s = g_core.default_scene; -// if (s.point_lights_count == 4) { -// WARN("Already 4 point lights, we can't add more."); -// } else { -// s.point_lights[s.point_lights_count] = light; -// s.point_lights_count++; -// } -// } -// void scene_add_model(model_handle model, transform3d transform) { -// render_entity renderable = { .model = model, .tf = transform }; -// render_entity_darray_push(g_core.default_scene.renderables, renderable); -// } - -// bool scene_remove_model(model_handle model) { -// scene s = g_core.default_scene; -// for (u32 i = 0; i <= s.renderables->len; i++) { -// if (s.renderables->data[i].model.raw == model.raw) { -// // TODO: add remove function to darray -// } -// } -// return true; -// } - -// void scene_set_model_transform(model_handle model, transform3d new_transform) { -// scene s = g_core.default_scene; -// for (u32 i = 0; i <= s.renderables->len; i++) { -// if (s.renderables->data[i].model.raw == model.raw) { -// s.renderables->data[i].tf = new_transform; -// } -// } -// } - -// void scene_set_camera(vec3 pos, vec3 front) { -// scene s = g_core.default_scene; -// s.camera.position = pos; -// s.camera.front = front; -// } diff --git a/src/scene.h b/src/scene.h deleted file mode 100644 index e414ea8..0000000 --- a/src/scene.h +++ /dev/null @@ -1,54 +0,0 @@ -/** - * @file scene.h - * @author your name (you@domain.com) - * @brief - * @version 0.1 - * @date 2024-04-27 - * - * @copyright Copyright (c) 2024 - * - */ -#pragma once -#include "camera.h" -#include "defines.h" -#include "maths_types.h" -#include "render_types.h" - -// typedef struct scene { -// // camera -// Camera camera; -// // lights -// DirectionalLight dir_light; -// PointLight point_lights[4]; -// size_t point_lights_count; -// // geometry -// render_entity_darray* renderables; -// // TODO: tree - transform_hierarchy -// } scene; - -// void scene_init(scene* s); -// void scene_free(scene* s); - -// Simplified API - no scene pointer; gets and sets global scene - -// Add/Remove objects from the scene -/* vec3 direction; */ -/* vec3 ambient; */ -/* vec3 diffuse; */ -/* vec3 specular; */ -// void scene_set_dir_light(directional_light light); -// void _scene_set_dir_light(vec3 ambient, vec3 diffuse, vec3 specular, vec3 direction); - -// void scene_add_point_light(point_light light); -// void scene_add_model(model_handle model, transform3d transform); -// bool scene_remove_model(model_handle model); - -// // Getter & Setters -// void scene_set_model_transform(model_handle model, transform3d new_transform); -// void scene_set_camera(vec3 pos, vec3 front); - -/* // There can only be one heightmap terrain at a time right now. */ -/* bool scene_add_heightmap(scene* s /\* TODO *\/); */ -/* bool scene_delete_heightmap(scene* s); */ - -// TODO: functions to load and save scenes from disk diff --git a/src/std/containers/darray.h b/src/std/containers/darray.h index ebb5795..d8c1e6d 100644 --- a/src/std/containers/darray.h +++ b/src/std/containers/darray.h @@ -38,12 +38,6 @@ #define PREFIX static -/* if (arena != NULL) {\ */ -/* d = arena_alloc(arena, sizeof(T##_darray));\ */ -/* data = arena_alloc(arena, starting_capacity * sizeof(T));\ */ -/* } else {\ */ -/* }\ */ - #define KITC_DECL_TYPED_ARRAY(T) DECL_TYPED_ARRAY(T, T) #define DECL_TYPED_ARRAY(T, Type) \ diff --git a/src/std/str.h b/src/std/str.h index 9e712e6..c25c615 100644 --- a/src/std/str.h +++ b/src/std/str.h @@ -33,6 +33,8 @@ typedef struct { Str8 Str8_create(u8* buf, size_t len); +// TODO: Str8_OntoArena(arena* a, Str8 s); + /** @brief Return a null-terminated C string cloned onto an arena */ char* Str8_to_cstr(arena* a, Str8 s); diff --git a/src/ui/ui.h b/src/ui/ui.h deleted file mode 100644 index c5ace97..0000000 --- a/src/ui/ui.h +++ /dev/null @@ -1,13 +0,0 @@ -/** - * @brief - */ - -#pragma once -#include "defines.h" - -typedef struct UI_Storage UI_Storage; - -PUB bool UI_Init(UI_Storage* storage); -PUB void UI_Shutdown(UI_Storage* storage); - -// TODO: define immui api @@ -58,10 +58,9 @@ local core_sources = { "deps/glad/src/glad.c", "src/*.c", "src/core/*.c", - -- "src/logos/*.c", + "src/logos/*.c", "src/maths/*.c", "src/platform/*.c", - "src/physics/*.c", "src/ral/*.c", "src/ral/backends/opengl/*.c", "src/render/*.c", @@ -111,14 +110,13 @@ add_includedirs("deps/stb_truetype", { public = true }) add_includedirs("include/", { public = true }) add_includedirs("src/", { public = true }) add_includedirs("src/core", { public = true }) --- add_includedirs("src/logos/", {public = true}) +add_includedirs("src/logos/", { public = true }) add_includedirs("src/maths/", { public = true }) add_includedirs("src/platform/", { public = true }) -add_includedirs("src/physics/", { public = true }) add_includedirs("src/ral", { public = true }) add_includedirs("src/ral/backends/opengl", { public = true }) add_includedirs("src/render", { public = true }) -add_includedirs("src/ral/backends/vulkan", {public = true}) +add_includedirs("src/ral/backends/vulkan", { public = true }) add_includedirs("src/resources/", { public = true }) add_includedirs("src/std/", { public = true }) add_includedirs("src/std/containers", { public = true }) @@ -263,12 +261,12 @@ end -- add_files("examples/property_animation/ex_property_animation.c") -- set_rundir("$(projectdir)") --- target("skinned") --- set_kind("binary") --- set_group("examples") --- add_deps("core_shared") --- add_files("examples/skinned_animation/ex_skinned_animation.c") --- set_rundir("$(projectdir)") +target("skinned") +set_kind("binary") +set_group("examples") +add_deps("core_shared") +add_files("examples/skinned_animation/ex_skinned_animation.c") +set_rundir("$(projectdir)") -- target("input") -- set_kind("binary") |