From 3d80fc2bcc2888ae5ce2d1334eb9ec30fac544ea Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Thu, 28 May 2026 21:00:11 -0400 Subject: window scrolling --- platform/desktop/desktop.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'platform') diff --git a/platform/desktop/desktop.c b/platform/desktop/desktop.c index 9574c9c..b156e56 100644 --- a/platform/desktop/desktop.c +++ b/platform/desktop/desktop.c @@ -45,6 +45,7 @@ typedef struct { GLint uniform_tex_loc; GLuint screen_handle; uint32_t typed; + double scroll; } Desktop_Platform; Desktop_Platform p; @@ -56,6 +57,15 @@ void character_callback(GLFWwindow *window, unsigned int cp) p.typed = cp; } +static +void scroll_callback(GLFWwindow* window, double x, double y) +{ + (void)window; + (void)x; + p.scroll = y; +} + + static GLuint compile_shader(GLenum type, const char *src) { @@ -102,6 +112,7 @@ void ty_platform_init(ty_Ctx *ctx) ty_log_fatal(TY_PLATFORM_ERR, "could not load GLAD"); glfwSetCharCallback(p.win, character_callback); + glfwSetScrollCallback(p.win, scroll_callback); ty_Vec2 vertices[] = { ty_vec2(-1, -1), ty_vec2(0, 1), @@ -180,6 +191,8 @@ void ty_platform_deinit(void) void ty_platform_frame(ty_Image img) { + p.scroll = 0; + glfwPollEvents(); int win_width, win_height; @@ -283,3 +296,8 @@ bool ty_platform_get_typed_char(uint32_t *c) p.typed = 0; return true; } + +int ty_platform_get_scroll(void) +{ + return (int)p.scroll; +} -- cgit v1.3-2-g0d8e