aboutsummaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-28 21:00:11 -0400
committeriamcheeseman <[email protected]>2026-05-28 21:00:11 -0400
commit3d80fc2bcc2888ae5ce2d1334eb9ec30fac544ea (patch)
treec968f1b32f884b550cc7fb54f906d94a995f1680 /platform
parent78520499d6c444e435879eef1ac96cdff9e6c4d1 (diff)
window scrolling
Diffstat (limited to 'platform')
-rw-r--r--platform/desktop/desktop.c18
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;
+}