summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-02-24 22:54:04 +1100
committerOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-02-24 22:54:04 +1100
commitb38313c518d99a43c8a2438ea20f1cf84636d794 (patch)
tree5bbaefe6bc1d36c6184c18a129bff3bab91465ac /src
parentb27cfd40b88a4c2689560b3d3235c8579b9778f6 (diff)
add handle def macro
Diffstat (limited to 'src')
-rw-r--r--src/defines.h7
-rw-r--r--src/renderer/render_types.h10
-rw-r--r--src/systems/text.h6
3 files changed, 17 insertions, 6 deletions
diff --git a/src/defines.h b/src/defines.h
index 79b735d..52aa7b0 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -42,6 +42,13 @@ _Static_assert(sizeof(ptrdiff_t) == 8, "");
#define alignof(x) _Alignof(x)
+// Wrap a u32 to make a type-safe "handle" or ID
+#define CORE_DEFINE_HANDLE(name) \
+ typedef struct name name; \
+ struct name { \
+ u32 raw; \
+ }
+
/*
Possible platform defines:
#define CEL_PLATFORM_LINUX 1
diff --git a/src/renderer/render_types.h b/src/renderer/render_types.h
index 896a1a5..a3639e7 100644
--- a/src/renderer/render_types.h
+++ b/src/renderer/render_types.h
@@ -12,6 +12,16 @@
struct GLFWwindow;
+#ifndef RESOURCE_HANDLE_DEFS
+CORE_DEFINE_HANDLE(texture_handle);
+#define RESOURCE_HANDLE_DEFS
+#endif
+
+/* @brief Opaque wrapper around a shader program */
+typedef struct shader {
+ u32 program_id;
+} shader;
+
/** @brief configuration passed to the renderer at init time */
typedef struct renderer_config {
char window_name[256];
diff --git a/src/systems/text.h b/src/systems/text.h
index 3c580df..19248a6 100644
--- a/src/systems/text.h
+++ b/src/systems/text.h
@@ -10,12 +10,6 @@
#include "render_types.h"
struct core;
-typedef struct texture_handle {
- u32 raw
-} texture_handle;
-typedef struct shader {
- u32 raw
-} shader;
/** @brief internal font struct */
typedef struct font {