add callbacks for mouse movement and mouse clicking

This commit is contained in:
2024-07-30 17:10:48 +01:00
parent 75b82fd888
commit e97768b18a
12 changed files with 102 additions and 49 deletions

25
ffi/glfw-input.c Normal file
View File

@@ -0,0 +1,25 @@
#include "export.h"
#include <GLFW/glfw3.h>
int MOUSE_PRESSED = GLFW_PRESS;
int MOUSE_RELEASED = GLFW_RELEASE;
int LEFT_MOUSE_BUTTON = GLFW_MOUSE_BUTTON_1;
// Calls function exported from SML
void mouseMoveCallback(GLFWwindow *window, double xpos, double ypos) {
mltonMouseMoveCallback((int)xpos, (int)ypos);
}
void mouseClickCallback(GLFWwindow *window, int button, int action, int mods) {
mltonMouseClickCallback(button, action);
}
// Call this from MLton to register key callback with GLFW.
void setMouseMoveCallback(GLFWwindow *window) {
glfwSetCursorPosCallback(window, mouseMoveCallback);
}
void setMouseClickCallback(GLFWwindow *window) {
glfwSetMouseButtonCallback(window, mouseClickCallback);
}