summaryrefslogtreecommitdiff
path: root/src/systems/text.h
diff options
context:
space:
mode:
authorOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-02-24 22:47:46 +1100
committerOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-02-24 22:47:46 +1100
commit7b3afcaf77f96e7d62f6cd1623ead7f17512d79f (patch)
treeb5f82c64e9c06a84e4d095ab4ac48712e860b673 /src/systems/text.h
parentb047be5252aeb981faea077409c1768fda0301d9 (diff)
repo init. partial port of existing code
Diffstat (limited to 'src/systems/text.h')
-rw-r--r--src/systems/text.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/systems/text.h b/src/systems/text.h
new file mode 100644
index 0000000..3c580df
--- /dev/null
+++ b/src/systems/text.h
@@ -0,0 +1,58 @@
+/**
+ * @brief
+ */
+#pragma once
+
+#include <stb_truetype.h>
+
+#include "darray.h"
+#include "defines.h"
+#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 {
+ const char *name;
+ stbtt_fontinfo stbtt_font;
+ stbtt_bakedchar c_data[96];
+ texture_handle bitmap_tex;
+} font;
+
+typedef struct draw_text_packet {
+ char *contents;
+ f32 x;
+ f32 y;
+} draw_text_packet;
+
+KITC_DECL_TYPED_ARRAY(draw_text_packet)
+
+typedef struct text_system_state {
+ font default_font;
+ shader glyph_shader;
+ u32 glyph_vbo;
+ u32 glyph_vao;
+ draw_text_packet_darray *draw_cmd_buf;
+ // TODO: fonts array or hashtable
+} text_system_state;
+
+void text_system_render(text_system_state *text);
+
+// --- Lifecycle functions
+bool text_system_init(text_system_state *text);
+void text_system_shutdown(text_system_state *text);
+
+// --- Drawing
+
+/**
+ * @brief immediate mode draw text.
+ * @note immediately emits draw calls causing a shader program switch if you weren't previously
+ drawing text in the current frame.
+*/
+void draw_text(struct core *core, f32 x, f32 y, char *contents); \ No newline at end of file