diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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 | |||
12 | static char text[2048]; | ||
13 | static 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 | ||
35 | void | ||
36 | glfw_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. |
33 | struct Letter { | 42 | struct Letter { |
34 | f32 x; | 43 | f32 x; |
@@ -304,6 +313,7 @@ void | |||
304 | setup_callbacks(Context *ctx) { | 313 | setup_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 | ||
309 | void | 319 | void |
@@ -355,7 +365,7 @@ add_text(Context *ctx, char *txt) { | |||
355 | void | 365 | void |
356 | update_text(Context *ctx) { | 366 | update_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, |