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

64 lines
1.8 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 (), 0)
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 ()
val initialModel = AppInit.fromWindowWidthAndHeight
( Constants.windowWidth
, Constants.windowHeight
, Constants.initialWidthClickPoints
, Constants.initialHeightClickPoints
)
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 ()
val squareDrawObject = AppDraw.initSquares ()
val modalTextDrawObject = AppDraw.initModalText ()
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 fileMailbox = Mailbox.mailbox ()
val _ = InputCallbacks.registerCallbacks (window, inputMailbox)
val _ = CML.spawn (fn () =>
UpdateThread.run (inputMailbox, drawMailbox, fileMailbox, 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
, squareDrawObject
2024-07-31 22:25:15 +01:00
, 0
, modalTextDrawObject
, 0
2024-07-31 22:25:15 +01:00
))
val _ = CML.spawn (fn () => FileThread.run (fileMailbox, inputMailbox))
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)