diff --git a/ffi/export.h b/ffi/export.h index d896f08..f09f8a4 100644 --- a/ffi/export.h +++ b/ffi/export.h @@ -1,5 +1,5 @@ -#ifndef __SHF_RGFW_ML_H__ -#define __SHF_RGFW_ML_H__ +#ifndef __SHF_ML_H__ +#define __SHF_ML_H__ /* Copyright (C) 2004-2007 Henry Cejtin, Matthew Fluet, Suresh * Jagannathan, and Stephen Weeks. @@ -132,23 +132,23 @@ typedef Pointer Objptr; #endif /* _MLTON_EXPORT_H_ */ -#if !defined(PART_OF_SHF_RGFW) && \ - !defined(STATIC_LINK_SHF_RGFW) && \ - !defined(DYNAMIC_LINK_SHF_RGFW) -#define PART_OF_SHF_RGFW +#if !defined(PART_OF_SHF) && \ + !defined(STATIC_LINK_SHF) && \ + !defined(DYNAMIC_LINK_SHF) +#define PART_OF_SHF #endif -#if defined(PART_OF_SHF_RGFW) +#if defined(PART_OF_SHF) #define MLLIB_PRIVATE(x) PRIVATE x #define MLLIB_PUBLIC(x) PUBLIC x -#elif defined(STATIC_LINK_SHF_RGFW) +#elif defined(STATIC_LINK_SHF) #define MLLIB_PRIVATE(x) #define MLLIB_PUBLIC(x) PUBLIC x -#elif defined(DYNAMIC_LINK_SHF_RGFW) +#elif defined(DYNAMIC_LINK_SHF) #define MLLIB_PRIVATE(x) #define MLLIB_PUBLIC(x) EXTERNAL x #else -#error Must specify linkage for shf_rgfw +#error Must specify linkage for shf #define MLLIB_PRIVATE(x) #define MLLIB_PUBLIC(x) #endif @@ -157,6 +157,9 @@ typedef Pointer Objptr; extern "C" { #endif +MLLIB_PUBLIC(void mltonFramebufferSizeCallback (Int32 x0, Int32 x1);) +MLLIB_PUBLIC(void mltonCharCallback (Word32 x0);) +MLLIB_PUBLIC(void mltonKeyCallback (Int32 x0, Int32 x1, Int32 x2, Int32 x3);) #undef MLLIB_PRIVATE #undef MLLIB_PUBLIC @@ -165,4 +168,4 @@ extern "C" { } #endif -#endif /* __SHF_RGFW_ML_H__ */ +#endif /* __SHF_ML_H__ */ diff --git a/shell/glfw-loop.sml b/shell/glfw-loop.sml index 64a8807..9f92b23 100644 --- a/shell/glfw-loop.sml +++ b/shell/glfw-loop.sml @@ -37,20 +37,6 @@ struct fun consumeEvents (drawState, window) = consumeEventsLoop (0, DrawMailbox.getMessagesAndClear (), drawState, window) - fun updateLoop (pos, msgVec, app) = - if pos = Vector.length msgVec then - app - else - let - val msg = Vector.sub (msgVec, pos) - val app = Updater.update (app, msg) - in - updateLoop (pos + 1, msgVec, app) - end - - fun update app = - updateLoop (0, InputMailbox.getMessagesAndClear (), app) - fun helpLoop (app, drawState, window, gamepad) = case Glfw.windowShouldClose window of false => @@ -62,10 +48,10 @@ struct (* one update reacting to gamepad events *) val (gamepad, actions) = GlfwGamepad.query gamepad - val app = updateLoop (0, Vector.fromList actions, app) + val app = Updater.updateLoop (0, Vector.fromList actions, app) (* one update reacting to keyboard events *) - val app = update app + val app = Updater.update app val _ = GlDraw.draw drawState val _ = Glfw.swapBuffers window diff --git a/shell/rgfw-loop.sml b/shell/rgfw-loop.sml index a82d94c..10cb2d5 100644 --- a/shell/rgfw-loop.sml +++ b/shell/rgfw-loop.sml @@ -7,6 +7,9 @@ struct let val _ = Gles3.clearColor (0.89, 0.89, 0.89, 1.0) val _ = Gles3.clear () + + val app = Updater.update app + val () = Rgfw.swapBuffers window in loop (window, app) diff --git a/shell/updater.sml b/shell/updater.sml index b217ff0..05ecc32 100644 --- a/shell/updater.sml +++ b/shell/updater.sml @@ -11,7 +11,7 @@ struct hd :: tl => let val () = sendMsg hd in sendMsgs tl end | [] => () - fun update (app: AppType.app_type, inputMsg) = + fun updateOne (app: AppType.app_type, inputMsg) = let val time = Time.now () @@ -30,4 +30,18 @@ struct in app end + + fun updateLoop (pos, msgVec, app) = + if pos = Vector.length msgVec then + app + else + let + val msg = Vector.sub (msgVec, pos) + val app = updateOne (app, msg) + in + updateLoop (pos + 1, msgVec, app) + end + + fun update app = + updateLoop (0, InputMailbox.getMessagesAndClear (), app) end diff --git a/shf-rgfw b/shf-rgfw index 83eeb01..2d99c29 100755 Binary files a/shf-rgfw and b/shf-rgfw differ diff --git a/todo.md b/todo.md index 3b7f5dc..463d967 100644 --- a/todo.md +++ b/todo.md @@ -1,8 +1,7 @@ # To-do list - Bind functions from RGFW (alternative back-end/window library) and have an option to use it + - Add key callbacks, resize callbacks, etc. + - Consume msgs stores in app - Bind gamepad functions from GLFW - - I have bindings for alpha letters, shift, enter and escape. - - I should learn layout next. - - After learning layout, I should design and implement symbols - Modify deletion functions to use `PersistentVector.delete` - Implement 'yj' motion and add tests for it