aboutsummaryrefslogtreecommitdiff
path: root/teensy/platform/gl
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-23 10:55:01 -0400
committeriamcheeseman <[email protected]>2026-05-23 10:55:01 -0400
commitc2ea095659dea04663b83fe5313173f209c9bb0b (patch)
tree9e9d79902a442bdf1bb2ef6b38507217574b673e /teensy/platform/gl
parent5d36dcd67478cdb235f39d2aecb3270aba954001 (diff)
tyui text input boxes
Diffstat (limited to 'teensy/platform/gl')
-rw-r--r--teensy/platform/gl/gl.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/teensy/platform/gl/gl.c b/teensy/platform/gl/gl.c
index c6b8194..9f9c8f5 100644
--- a/teensy/platform/gl/gl.c
+++ b/teensy/platform/gl/gl.c
@@ -43,11 +43,18 @@ typedef struct {
GLuint program;
GLint uniform_tex_loc;
GLuint screen_handle;
+ uint32_t typed;
} Gl_Platform;
Gl_Platform p;
static
+void character_callback(GLFWwindow *window, unsigned int cp)
+{
+ p.typed = cp;
+}
+
+static
GLuint compile_shader(GLenum type, const char *src)
{
GLuint shader = glCreateShader(type);
@@ -88,6 +95,8 @@ void ty_platform_init(ty_Ctx *ctx)
glfwMakeContextCurrent(p.win);
+ glfwSetCharCallback(p.win, character_callback);
+
ty_log_info("initializing GLAD...");
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
ty_log_fatal(TY_PLATFORM_ERR, "could not init GLAD");
@@ -248,6 +257,7 @@ bool ty_platform_is_button_down(ty_Button btn)
case TY_BTN_ACTION_4: res = glfwGetKey(p.win, GLFW_KEY_O); break;
case TY_BTN_DB_CTRL: res = glfwGetKey(p.win, GLFW_KEY_LEFT_CONTROL); break;
case TY_BTN_DB_SHIFT: res = glfwGetKey(p.win, GLFW_KEY_LEFT_SHIFT); break;
+ case TY_BTN_DB_BKSPACE: res = glfwGetKey(p.win, GLFW_KEY_BACKSPACE); break;
case TY_BTN_DB_LMB:
res = glfwGetMouseButton(p.win, GLFW_MOUSE_BUTTON_LEFT);
break;
@@ -261,3 +271,12 @@ bool ty_platform_is_button_down(ty_Button btn)
return res == GLFW_PRESS;
}
+
+bool ty_platform_get_typed_char(uint32_t *c)
+{
+ assert(c);
+ *c = p.typed;
+ if (p.typed == 0)
+ return false;
+ p.typed = 0;
+}