diff --git a/dotscape b/dotscape new file mode 100755 index 0000000..b9477e1 Binary files /dev/null and b/dotscape differ diff --git a/dotscape.mlb b/dotscape.mlb index 064d455..170d04c 100644 --- a/dotscape.mlb +++ b/dotscape.mlb @@ -1,5 +1,6 @@ $(SML_LIB)/basis/basis.mlb +(* FUNCTIONAL CORE *) ann "allowVectorExps true" in @@ -23,3 +24,26 @@ functional-core/app-with.sml message-types/input-msg.sml message-types/draw-msg.sml functional-core/app-update.sml + +(* IMPERATIVE SHELL *) +$(SML_LIB)/basis/mlton.mlb +$(SML_LIB)/cml/cml.mlb + +ann + "allowFFI true" +in + ffi/gles3-import.sml + ffi/glfw-import.sml + ffi/glfw-input.sml +end + +ann + "allowVectorExps true" +in + imperative-shell/constants.sml + imperative-shell/app-draw.sml +end + +imperative-shell/input-callbacks.sml +imperative-shell/event-loop.sml +imperative-shell/shell.sml diff --git a/ffi/export.h b/ffi/export.h index c1080ad..a697dec 100644 --- a/ffi/export.h +++ b/ffi/export.h @@ -157,6 +157,9 @@ typedef Pointer Objptr; extern "C" { #endif +MLLIB_PUBLIC(void mltonMouseMoveCallback (Real32 x0, Real32 x1);) +MLLIB_PUBLIC(void mltonMouseClickCallback (Int32 x0, Int32 x1);) +MLLIB_PUBLIC(void mltonFramebufferSizeCallback (Int32 x0, Int32 x1);) #undef MLLIB_PRIVATE #undef MLLIB_PUBLIC diff --git a/functional-core/app-init.sml b/functional-core/app-init.sml index 647ef75..c762cb6 100644 --- a/functional-core/app-init.sml +++ b/functional-core/app-init.sml @@ -1,6 +1,6 @@ -signature APP_INIT = +signature APP_INIT = sig - val fromWidthAndHeight : int * int -> AppType.app_type + val fromWindowWidthAndHeight: int * int -> AppType.app_type end structure AppInit :> APP_INIT = @@ -26,7 +26,7 @@ struct } end - fun fromWidthAndHeight (windowWidth, windowHeight) = + fun fromWindowWidthAndHeight (windowWidth, windowHeight) = if windowWidth = windowHeight then helpFromWidthAndHeight (windowWidth, windowHeight, 0, windowWidth, 0, windowHeight) diff --git a/imperative-shell/event-loop.sml b/imperative-shell/event-loop.sml index 1e781e9..f81f0bd 100644 --- a/imperative-shell/event-loop.sml +++ b/imperative-shell/event-loop.sml @@ -15,13 +15,7 @@ struct end in fun update (inputMailbox, drawMailbox, initial) = - loop - ( inputMailbox - , drawMailbox - , 0.0 - , 0.0 - , AppType.getInitial (Constants.windowWidth, Constants.windowHeight) - ) + loop (inputMailbox, drawMailbox, 0.0, 0.0, initial) end fun draw @@ -100,14 +94,11 @@ struct | RESIZE_TRIANGLES_BUTTONS_AND_GRAPH {triangles, graphLines} => let val _ = - AppDraw.uploadTrianglesVector - (triangleDrawObject, triangles) + AppDraw.uploadTrianglesVector (triangleDrawObject, triangles) val triangleDrawLength = Vector.length triangles div 2 - (* buttons are reset by setting buttonDrawLength to 0 *) - val _ = - AppDraw.uploadGraphLines - (graphDrawObject, graphLines) - val drawGraphLength = Vector.length graphLines div 2 + (* buttons are reset by setting buttonDrawLength to 0 *) + val _ = AppDraw.uploadGraphLines (graphDrawObject, graphLines) + val drawGraphLength = Vector.length graphLines div 2 in draw ( drawMailbox diff --git a/imperative-shell/shell.sml b/imperative-shell/shell.sml index 3eaa2e1..017925b 100644 --- a/imperative-shell/shell.sml +++ b/imperative-shell/shell.sml @@ -15,12 +15,18 @@ struct val _ = Glfw.makeContextCurrent window val _ = Gles3.loadGlad () - val initialModel = AppType.getInitial (Constants.windowWidth, Constants.windowHeight) + val initialModel = + AppInit.fromWindowWidthAndHeight + (Constants.windowWidth, Constants.windowHeight) - val graphLines = #graphLines initialModel + val graphLines = + let + open AppType + in + #graphLines initialModel + end val graphDrawObject = AppDraw.initGraphLines () - val _ = - AppDraw.uploadGraphLines (graphDrawObject, graphLines) + val _ = AppDraw.uploadGraphLines (graphDrawObject, graphLines) val buttonDrawObject = AppDraw.initButton () val triangleDrawObject = AppDraw.initTriangles () @@ -30,8 +36,8 @@ struct val _ = CML.spawn (fn () => InputCallbacks.registerCallbacks (window, inputMailbox)) - val _ = CML.spawn - (fn () => EventLoop.update (inputMailbox, drawMailbox, initialModel)) + val _ = CML.spawn (fn () => + EventLoop.update (inputMailbox, drawMailbox, initialModel)) val _ = CML.spawn (fn () => EventLoop.draw ( drawMailbox