restore imperative shell
This commit is contained in:
24
dotscape.mlb
24
dotscape.mlb
@@ -1,5 +1,6 @@
|
|||||||
$(SML_LIB)/basis/basis.mlb
|
$(SML_LIB)/basis/basis.mlb
|
||||||
|
|
||||||
|
(* FUNCTIONAL CORE *)
|
||||||
ann
|
ann
|
||||||
"allowVectorExps true"
|
"allowVectorExps true"
|
||||||
in
|
in
|
||||||
@@ -23,3 +24,26 @@ functional-core/app-with.sml
|
|||||||
message-types/input-msg.sml
|
message-types/input-msg.sml
|
||||||
message-types/draw-msg.sml
|
message-types/draw-msg.sml
|
||||||
functional-core/app-update.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
|
||||||
|
|||||||
@@ -157,6 +157,9 @@ typedef Pointer Objptr;
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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_PRIVATE
|
||||||
#undef MLLIB_PUBLIC
|
#undef MLLIB_PUBLIC
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
signature APP_INIT =
|
signature APP_INIT =
|
||||||
sig
|
sig
|
||||||
val fromWidthAndHeight : int * int -> AppType.app_type
|
val fromWindowWidthAndHeight: int * int -> AppType.app_type
|
||||||
end
|
end
|
||||||
|
|
||||||
structure AppInit :> APP_INIT =
|
structure AppInit :> APP_INIT =
|
||||||
@@ -26,7 +26,7 @@ struct
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
fun fromWidthAndHeight (windowWidth, windowHeight) =
|
fun fromWindowWidthAndHeight (windowWidth, windowHeight) =
|
||||||
if windowWidth = windowHeight then
|
if windowWidth = windowHeight then
|
||||||
helpFromWidthAndHeight
|
helpFromWidthAndHeight
|
||||||
(windowWidth, windowHeight, 0, windowWidth, 0, windowHeight)
|
(windowWidth, windowHeight, 0, windowWidth, 0, windowHeight)
|
||||||
|
|||||||
@@ -15,13 +15,7 @@ struct
|
|||||||
end
|
end
|
||||||
in
|
in
|
||||||
fun update (inputMailbox, drawMailbox, initial) =
|
fun update (inputMailbox, drawMailbox, initial) =
|
||||||
loop
|
loop (inputMailbox, drawMailbox, 0.0, 0.0, initial)
|
||||||
( inputMailbox
|
|
||||||
, drawMailbox
|
|
||||||
, 0.0
|
|
||||||
, 0.0
|
|
||||||
, AppType.getInitial (Constants.windowWidth, Constants.windowHeight)
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
fun draw
|
fun draw
|
||||||
@@ -100,13 +94,10 @@ struct
|
|||||||
| RESIZE_TRIANGLES_BUTTONS_AND_GRAPH {triangles, graphLines} =>
|
| RESIZE_TRIANGLES_BUTTONS_AND_GRAPH {triangles, graphLines} =>
|
||||||
let
|
let
|
||||||
val _ =
|
val _ =
|
||||||
AppDraw.uploadTrianglesVector
|
AppDraw.uploadTrianglesVector (triangleDrawObject, triangles)
|
||||||
(triangleDrawObject, triangles)
|
|
||||||
val triangleDrawLength = Vector.length triangles div 2
|
val triangleDrawLength = Vector.length triangles div 2
|
||||||
(* buttons are reset by setting buttonDrawLength to 0 *)
|
(* buttons are reset by setting buttonDrawLength to 0 *)
|
||||||
val _ =
|
val _ = AppDraw.uploadGraphLines (graphDrawObject, graphLines)
|
||||||
AppDraw.uploadGraphLines
|
|
||||||
(graphDrawObject, graphLines)
|
|
||||||
val drawGraphLength = Vector.length graphLines div 2
|
val drawGraphLength = Vector.length graphLines div 2
|
||||||
in
|
in
|
||||||
draw
|
draw
|
||||||
|
|||||||
@@ -15,12 +15,18 @@ struct
|
|||||||
val _ = Glfw.makeContextCurrent window
|
val _ = Glfw.makeContextCurrent window
|
||||||
val _ = Gles3.loadGlad ()
|
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 graphDrawObject = AppDraw.initGraphLines ()
|
||||||
val _ =
|
val _ = AppDraw.uploadGraphLines (graphDrawObject, graphLines)
|
||||||
AppDraw.uploadGraphLines (graphDrawObject, graphLines)
|
|
||||||
|
|
||||||
val buttonDrawObject = AppDraw.initButton ()
|
val buttonDrawObject = AppDraw.initButton ()
|
||||||
val triangleDrawObject = AppDraw.initTriangles ()
|
val triangleDrawObject = AppDraw.initTriangles ()
|
||||||
@@ -30,8 +36,8 @@ struct
|
|||||||
|
|
||||||
val _ = CML.spawn (fn () =>
|
val _ = CML.spawn (fn () =>
|
||||||
InputCallbacks.registerCallbacks (window, inputMailbox))
|
InputCallbacks.registerCallbacks (window, inputMailbox))
|
||||||
val _ = CML.spawn
|
val _ = CML.spawn (fn () =>
|
||||||
(fn () => EventLoop.update (inputMailbox, drawMailbox, initialModel))
|
EventLoop.update (inputMailbox, drawMailbox, initialModel))
|
||||||
val _ = CML.spawn (fn () =>
|
val _ = CML.spawn (fn () =>
|
||||||
EventLoop.draw
|
EventLoop.draw
|
||||||
( drawMailbox
|
( drawMailbox
|
||||||
|
|||||||
Reference in New Issue
Block a user