progrfess scaffolding rgfw (next: consume events and add callbacks for events)
This commit is contained in:
25
ffi/export.h
25
ffi/export.h
@@ -1,5 +1,5 @@
|
|||||||
#ifndef __SHF_RGFW_ML_H__
|
#ifndef __SHF_ML_H__
|
||||||
#define __SHF_RGFW_ML_H__
|
#define __SHF_ML_H__
|
||||||
|
|
||||||
/* Copyright (C) 2004-2007 Henry Cejtin, Matthew Fluet, Suresh
|
/* Copyright (C) 2004-2007 Henry Cejtin, Matthew Fluet, Suresh
|
||||||
* Jagannathan, and Stephen Weeks.
|
* Jagannathan, and Stephen Weeks.
|
||||||
@@ -132,23 +132,23 @@ typedef Pointer Objptr;
|
|||||||
|
|
||||||
#endif /* _MLTON_EXPORT_H_ */
|
#endif /* _MLTON_EXPORT_H_ */
|
||||||
|
|
||||||
#if !defined(PART_OF_SHF_RGFW) && \
|
#if !defined(PART_OF_SHF) && \
|
||||||
!defined(STATIC_LINK_SHF_RGFW) && \
|
!defined(STATIC_LINK_SHF) && \
|
||||||
!defined(DYNAMIC_LINK_SHF_RGFW)
|
!defined(DYNAMIC_LINK_SHF)
|
||||||
#define PART_OF_SHF_RGFW
|
#define PART_OF_SHF
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PART_OF_SHF_RGFW)
|
#if defined(PART_OF_SHF)
|
||||||
#define MLLIB_PRIVATE(x) PRIVATE x
|
#define MLLIB_PRIVATE(x) PRIVATE x
|
||||||
#define MLLIB_PUBLIC(x) PUBLIC x
|
#define MLLIB_PUBLIC(x) PUBLIC x
|
||||||
#elif defined(STATIC_LINK_SHF_RGFW)
|
#elif defined(STATIC_LINK_SHF)
|
||||||
#define MLLIB_PRIVATE(x)
|
#define MLLIB_PRIVATE(x)
|
||||||
#define MLLIB_PUBLIC(x) PUBLIC x
|
#define MLLIB_PUBLIC(x) PUBLIC x
|
||||||
#elif defined(DYNAMIC_LINK_SHF_RGFW)
|
#elif defined(DYNAMIC_LINK_SHF)
|
||||||
#define MLLIB_PRIVATE(x)
|
#define MLLIB_PRIVATE(x)
|
||||||
#define MLLIB_PUBLIC(x) EXTERNAL x
|
#define MLLIB_PUBLIC(x) EXTERNAL x
|
||||||
#else
|
#else
|
||||||
#error Must specify linkage for shf_rgfw
|
#error Must specify linkage for shf
|
||||||
#define MLLIB_PRIVATE(x)
|
#define MLLIB_PRIVATE(x)
|
||||||
#define MLLIB_PUBLIC(x)
|
#define MLLIB_PUBLIC(x)
|
||||||
#endif
|
#endif
|
||||||
@@ -157,6 +157,9 @@ typedef Pointer Objptr;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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_PRIVATE
|
||||||
#undef MLLIB_PUBLIC
|
#undef MLLIB_PUBLIC
|
||||||
@@ -165,4 +168,4 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __SHF_RGFW_ML_H__ */
|
#endif /* __SHF_ML_H__ */
|
||||||
|
|||||||
@@ -37,20 +37,6 @@ struct
|
|||||||
fun consumeEvents (drawState, window) =
|
fun consumeEvents (drawState, window) =
|
||||||
consumeEventsLoop (0, DrawMailbox.getMessagesAndClear (), 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) =
|
fun helpLoop (app, drawState, window, gamepad) =
|
||||||
case Glfw.windowShouldClose window of
|
case Glfw.windowShouldClose window of
|
||||||
false =>
|
false =>
|
||||||
@@ -62,10 +48,10 @@ struct
|
|||||||
|
|
||||||
(* one update reacting to gamepad events *)
|
(* one update reacting to gamepad events *)
|
||||||
val (gamepad, actions) = GlfwGamepad.query gamepad
|
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 *)
|
(* one update reacting to keyboard events *)
|
||||||
val app = update app
|
val app = Updater.update app
|
||||||
val _ = GlDraw.draw drawState
|
val _ = GlDraw.draw drawState
|
||||||
|
|
||||||
val _ = Glfw.swapBuffers window
|
val _ = Glfw.swapBuffers window
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ struct
|
|||||||
let
|
let
|
||||||
val _ = Gles3.clearColor (0.89, 0.89, 0.89, 1.0)
|
val _ = Gles3.clearColor (0.89, 0.89, 0.89, 1.0)
|
||||||
val _ = Gles3.clear ()
|
val _ = Gles3.clear ()
|
||||||
|
|
||||||
|
val app = Updater.update app
|
||||||
|
|
||||||
val () = Rgfw.swapBuffers window
|
val () = Rgfw.swapBuffers window
|
||||||
in
|
in
|
||||||
loop (window, app)
|
loop (window, app)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ struct
|
|||||||
hd :: tl => let val () = sendMsg hd in sendMsgs tl end
|
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
|
let
|
||||||
val time = Time.now ()
|
val time = Time.now ()
|
||||||
|
|
||||||
@@ -30,4 +30,18 @@ struct
|
|||||||
in
|
in
|
||||||
app
|
app
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
5
todo.md
5
todo.md
@@ -1,8 +1,7 @@
|
|||||||
# To-do list
|
# To-do list
|
||||||
- Bind functions from RGFW (alternative back-end/window library) and have an option to use it
|
- 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
|
- 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`
|
- Modify deletion functions to use `PersistentVector.delete`
|
||||||
- Implement 'yj' motion and add tests for it
|
- Implement 'yj' motion and add tests for it
|
||||||
|
|||||||
Reference in New Issue
Block a user