diff options
author | Omni <omniscient.oce@gmail.com> | 2024-08-18 14:03:25 +1000 |
---|---|---|
committer | Omni <omniscient.oce@gmail.com> | 2024-08-18 14:03:25 +1000 |
commit | be8ab99b38c25e899008582d68e891150b328a4d (patch) | |
tree | 3261b3087072434424e937f82479f9d15b28106c | |
parent | 10a97636c5a0234ca776097bae4be25dcf3c050e (diff) |
start on stack array
-rw-r--r-- | examples/game_demo/game_demo.c | 8 | ||||
-rw-r--r-- | src/animation.h | 1 | ||||
-rw-r--r-- | src/std/containers/stack_array.h | 19 |
3 files changed, 27 insertions, 1 deletions
diff --git a/examples/game_demo/game_demo.c b/examples/game_demo/game_demo.c index 69023d7..76bc295 100644 --- a/examples/game_demo/game_demo.c +++ b/examples/game_demo/game_demo.c @@ -11,6 +11,7 @@ #include "input.h" #include "keys.h" #include "loaders.h" +#include "log.h" #include "maths.h" #include "maths_types.h" #include "pbr.h" @@ -20,12 +21,19 @@ #include "render_types.h" #include "shadows.h" #include "skybox.h" +#include "stack_array.h" #include "terrain.h" static const char* faces[6] = { "assets/skybox/right.jpg", "assets/skybox/left.jpg", "assets/skybox/top.jpg", "assets/skybox/bottom.jpg", "assets/skybox/front.jpg", "assets/skybox/back.jpg" }; +typedef struct Thing { + float x; +} Thing; + +TYPED_STACK_ARRAY(Thing, Thing, 6); + int main() { Core_Bringup("Celeritas: Game Demo", NULL); diff --git a/src/animation.h b/src/animation.h index 2a489b8..5883f13 100644 --- a/src/animation.h +++ b/src/animation.h @@ -4,7 +4,6 @@ #include "darray.h" #include "defines.h" #include "maths_types.h" -#include "mem.h" #include "ral_types.h" typedef enum Interpolation { diff --git a/src/std/containers/stack_array.h b/src/std/containers/stack_array.h new file mode 100644 index 0000000..d2b6bdd --- /dev/null +++ b/src/std/containers/stack_array.h @@ -0,0 +1,19 @@ +#pragma once +#include <stdbool.h> + +// Defines "_sarray" types + +#define TYPED_STACK_ARRAY(T, Name, Len) \ + typedef struct Name##_sarray { \ + T items[ Len ]; \ + size_t len; \ + } Name##_sarray; \ + Name##_sarray Name##_sarray_create() { \ + Name##_sarray arr = { .len = 0 }; \ + return arr; \ + } \ + bool Name##_sarray_push(Name##_sarray* arr, T item) { \ + if (arr->len == Len) { return false; }\ + arr->items[arr->len++] = item;\ + return true;\ + } |