Files
sml-projects/imperative-shell/shell.sml

53 lines
1.5 KiB
Standard ML
Raw Normal View History

2024-07-28 14:22:17 +01:00
structure Shell =
struct
open CML
fun main () =
let
(* Set up GLFW. *)
val _ = Glfw.init ()
val _ = Glfw.windowHint (Glfw.CONTEXT_VERSION_MAJOR (), 3)
val _ = Glfw.windowHint (Glfw.DEPRECATED (), Glfw.FALSE ())
val _ = Glfw.windowHint (Glfw.SAMPLES (), 4)
2024-07-31 22:25:15 +01:00
val window =
Glfw.createWindow
2024-08-01 20:52:20 +01:00
(Constants.windowWidth, Constants.windowHeight, "Dotscape")
2024-07-28 14:22:17 +01:00
val _ = Glfw.makeContextCurrent window
val _ = Gles3.loadGlad ()
2024-08-08 05:56:20 +01:00
val initialModel =
AppInit.fromWindowWidthAndHeight
(Constants.windowWidth, Constants.windowHeight)
val graphLines = GraphLines.generate initialModel
val graphDrawObject = AppDraw.initGraphLines ()
2024-08-08 05:56:20 +01:00
val _ = AppDraw.uploadGraphLines (graphDrawObject, graphLines)
val dotDrawObject = AppDraw.initDot ()
2024-07-31 22:25:15 +01:00
val triangleDrawObject = AppDraw.initTriangles ()
2024-07-28 14:22:17 +01:00
val inputMailbox = Mailbox.mailbox ()
2024-07-31 12:00:07 +01:00
val drawMailbox = Mailbox.mailbox ()
val _ = CML.spawn (fn () =>
InputCallbacks.registerCallbacks (window, inputMailbox))
2024-08-08 05:56:20 +01:00
val _ = CML.spawn (fn () =>
UpdateThread.run (inputMailbox, drawMailbox, initialModel))
val _ = CML.spawn (fn () =>
DrawThread.run
2024-07-31 22:25:15 +01:00
( drawMailbox
, window
, graphDrawObject
, Vector.length graphLines div 2
, dotDrawObject
2024-07-31 22:25:15 +01:00
, 0
, triangleDrawObject
, 0
))
2024-07-28 14:22:17 +01:00
in
2024-07-31 12:00:07 +01:00
()
2024-07-28 14:22:17 +01:00
end
end
val _ = RunCML.doit (Shell.main, NONE)