diff options
Diffstat (limited to 'platform/desktop/desktop.c')
| -rw-r--r-- | platform/desktop/desktop.c | 18 |
1 files changed, 18 insertions, 0 deletions
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; @@ -57,6 +58,15 @@ void character_callback(GLFWwindow *window, unsigned int 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) { GLuint shader = glCreateShader(type); @@ -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; +} |
