summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 7a8b6e7..32be6c7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -7,7 +7,10 @@
7#include "shorthand.h" 7#include "shorthand.h"
8#include "bd-font.c" 8#include "bd-font.c"
9 9
10#define TEXT_OVERLAY_SIZE 5 10#define TEXT_OVERLAY_SIZE 4
11
12static char text[2048];
13static u32 text_n = 0;
11 14
12// 15//
13// Callbacks. 16// Callbacks.
@@ -29,6 +32,12 @@ glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
29 } 32 }
30} 33}
31 34
35void
36glfw_text_callback(GLFWwindow* window, unsigned int codepoint) {
37 (void)window;
38 text[text_n++] = codepoint;
39}
40
32// Letter for a the monospace text overlay layer. 41// Letter for a the monospace text overlay layer.
33struct Letter { 42struct Letter {
34 f32 x; 43 f32 x;
@@ -304,6 +313,7 @@ void
304setup_callbacks(Context *ctx) { 313setup_callbacks(Context *ctx) {
305 glfwSetErrorCallback(glfw_error_callback); 314 glfwSetErrorCallback(glfw_error_callback);
306 glfwSetKeyCallback(ctx->window, glfw_key_callback); 315 glfwSetKeyCallback(ctx->window, glfw_key_callback);
316 glfwSetCharCallback(ctx->window, glfw_text_callback);
307} 317}
308 318
309void 319void
@@ -355,7 +365,7 @@ add_text(Context *ctx, char *txt) {
355void 365void
356update_text(Context *ctx) { 366update_text(Context *ctx) {
357 clear_text(ctx); 367 clear_text(ctx);
358 add_text(ctx, "hello world!"); 368 add_text(ctx, text);
359 369
360 glBindBuffer(GL_ARRAY_BUFFER, ctx->text_overlay.vbo); 370 glBindBuffer(GL_ARRAY_BUFFER, ctx->text_overlay.vbo);
361 glBufferData(GL_ARRAY_BUFFER, 371 glBufferData(GL_ARRAY_BUFFER,