a little refactoring

This commit is contained in:
2024-07-31 10:03:30 +01:00
parent 6edb4f2556
commit 94611eceee
5 changed files with 41 additions and 41 deletions

View File

@@ -2,37 +2,6 @@ structure Shell =
struct
open CML
fun callbackListener mailbox =
let
open InputMessage
val _ =
case Mailbox.recv mailbox of
MOUSE_MOVE {x, y} =>
print (String.concat
["x pos: ", Int.toString x, ", y pos: ", Int.toString y, "\n"])
| MOUSE_LEFT_CLICK => print "clicked mouse\n"
| MOUSE_LEFT_RELEASE => print "released mouse\n"
in
callbackListener mailbox
end
fun loop (window, graphDrawObject, buttonDrawObject) =
if not (Glfw.windowShouldClose window) then
let
val _ = Gles3.clearColor (1.0, 1.0, 1.0, 1.0)
val _ = Gles3.clear ()
val _ = AppDraw.drawGraphLines graphDrawObject
val _ = AppDraw.drawButton (buttonDrawObject, #[])
val _ = Glfw.pollEvents ()
val _ = Glfw.swapBuffers window
in
loop (window, graphDrawObject, buttonDrawObject)
end
else
Glfw.terminate ()
fun main () =
let
(* Set up GLFW. *)
@@ -63,9 +32,9 @@ struct
()
end)
(* Set callback listener *)
val _ = CML.spawn (fn () => callbackListener inputMailbox)
val _ = CML.spawn (fn () => EventLoop.update inputMailbox)
in
loop (window, graphDrawObject, buttonDrawObject)
EventLoop.draw (window, graphDrawObject, buttonDrawObject, 0)
end
end