scaffolding in preparation for implementing undo

This commit is contained in:
2024-08-08 06:34:40 +01:00
parent a53c5e1ce3
commit 5c7c61586a
10 changed files with 53 additions and 10 deletions

View File

@@ -160,6 +160,7 @@ extern "C" {
MLLIB_PUBLIC(void mltonMouseMoveCallback (Real32 x0, Real32 x1);)
MLLIB_PUBLIC(void mltonMouseClickCallback (Int32 x0, Int32 x1);)
MLLIB_PUBLIC(void mltonFramebufferSizeCallback (Int32 x0, Int32 x1);)
MLLIB_PUBLIC(void mltonKeyCallback (Int32 x0, Int32 x1, Int32 x2, Int32 x3);)
#undef MLLIB_PRIVATE
#undef MLLIB_PUBLIC

View File

@@ -1,9 +1,10 @@
#include "export.h"
#include <GLFW/glfw3.h>
int MOUSE_PRESSED = GLFW_PRESS;
int MOUSE_RELEASED = GLFW_RELEASE;
int PRESS = GLFW_PRESS;
int RELEASE = GLFW_RELEASE;
int LEFT_MOUSE_BUTTON = GLFW_MOUSE_BUTTON_1;
int KEY_Z = GLFW_KEY_Z;
// Calls function exported from SML
void mouseMoveCallback(GLFWwindow *window, double xpos, double ypos) {
@@ -28,3 +29,10 @@ void framebufferSizeCallback(GLFWwindow *window, int width, int height) {
void setFramebufferSizeCallback(GLFWwindow *window, int width, int height) {
glfwSetFramebufferSizeCallback(window, framebufferSizeCallback);
}
void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) {
mltonKeyCallback(key, scancode, action, mods);
}
void setKeyCallback(GLFWwindow *window) {
glfwSetKeyCallback(window, keyCallback);
}

View File

@@ -19,10 +19,18 @@ struct
_import "setFramebufferSizeCallback" public reentrant : window -> unit;
(* Constants for mouse input. *)
val (MOUSE_PRESSED, _) =
_symbol "MOUSE_PRESSED" public : ( unit -> int ) * ( int -> unit );
val (MOUSE_RELEASED, _) =
_symbol "MOUSE_RELEASED" public : ( unit -> int ) * ( int -> unit );
val (PRESS, _) =
_symbol "PRESS" public : ( unit -> int ) * ( int -> unit );
val (RELEASE, _) =
_symbol "RELEASE" public : ( unit -> int ) * ( int -> unit );
val (LEFT_MOUSE_BUTTON, _) =
_symbol "LEFT_MOUSE_BUTTON" public : ( unit -> int ) * ( int -> unit );
(* Key input *)
val exportKeyCallback =
_export "mltonKeyCallback" public : (int * int * int * int -> unit) -> unit;
val setKeyCallback = _import "setKeyCallback" public reentrant : window -> unit;
val (KEY_Z, _) =
_symbol "KEY_Z" public : ( unit -> int ) * ( int -> unit );
end