diff --git a/dotscape b/dotscape index 309c411..9eae057 100755 Binary files a/dotscape and b/dotscape differ diff --git a/functional-core/app-type.sml b/functional-core/app-type.sml index 364d946..7631ccb 100644 --- a/functional-core/app-type.sml +++ b/functional-core/app-type.sml @@ -247,7 +247,22 @@ struct else (* windowWidth < windowHeight *) let - (* todo; fix based on windowWidth > windowHeight *) + val difference = windowHeight - windowWidth + val offset = difference div 2 + + val halfWidth = Real32.fromInt (windowWidth div 2) + val halfHeight = Real32.fromInt (windowHeight div 2) + + val start = offset - (windowHeight div 2) + val start = Real32.fromInt start / halfHeight + + val finish = (windowHeight - offset) - (windowHeight div 2) + val finish = Real32.fromInt finish / halfHeight + + val lines = helpGenGraphLinesHorizontal + (0, xClickPoints, [], halfWidth, ~1.0, 1.0) + val lines = helpGenGraphLinesVertical + (0, yClickPoints, lines, halfHeight, start, finish) in Vector.fromList [] end diff --git a/imperative-shell/app-draw.sml b/imperative-shell/app-draw.sml index 0372643..d1b1ee5 100644 --- a/imperative-shell/app-draw.sml +++ b/imperative-shell/app-draw.sml @@ -41,11 +41,7 @@ struct val _ = Gles3.bindBuffer vertexBuffer val _ = - Gles3.bufferData - ( Constants.graphLines - , Vector.length Constants.graphLines - , Gles3.STATIC_DRAW () - ) + Gles3.bufferData (#[], 0, Gles3.STATIC_DRAW ()) val _ = Gles3.vertexAttribPointer (0, 2, 2, 0) val _ = Gles3.enableVertexAttribArray 0 in diff --git a/imperative-shell/constants.sml b/imperative-shell/constants.sml index 8937c16..ea3626e 100644 --- a/imperative-shell/constants.sml +++ b/imperative-shell/constants.sml @@ -40,9 +40,4 @@ struct \{\n\ \ FragColor = vec4(frag_col.x, frag_col.y, frag_col.z, 1.0f);\n\ \}" - - (* Todo: fix. Currently an empty vector which is not desired result, - * but changing vector dynamically (through resizing) works as desired. *) - val graphLines: Real32.real vector = - Vector.fromList [] end diff --git a/imperative-shell/event-loop.sml b/imperative-shell/event-loop.sml index 4e28523..70c498a 100644 --- a/imperative-shell/event-loop.sml +++ b/imperative-shell/event-loop.sml @@ -14,7 +14,7 @@ struct loop (inputMailbox, drawMailbox, mouseX, mouseY, model) end in - fun update (inputMailbox, drawMailbox) = + fun update (inputMailbox, drawMailbox, initial) = loop ( inputMailbox , drawMailbox diff --git a/imperative-shell/shell.sml b/imperative-shell/shell.sml index de04314..3eaa2e1 100644 --- a/imperative-shell/shell.sml +++ b/imperative-shell/shell.sml @@ -15,7 +15,13 @@ struct val _ = Glfw.makeContextCurrent window val _ = Gles3.loadGlad () + val initialModel = AppType.getInitial (Constants.windowWidth, Constants.windowHeight) + + val graphLines = #graphLines initialModel val graphDrawObject = AppDraw.initGraphLines () + val _ = + AppDraw.uploadGraphLines (graphDrawObject, graphLines) + val buttonDrawObject = AppDraw.initButton () val triangleDrawObject = AppDraw.initTriangles () @@ -24,13 +30,14 @@ struct val _ = CML.spawn (fn () => InputCallbacks.registerCallbacks (window, inputMailbox)) - val _ = CML.spawn (fn () => EventLoop.update (inputMailbox, drawMailbox)) + val _ = CML.spawn + (fn () => EventLoop.update (inputMailbox, drawMailbox, initialModel)) val _ = CML.spawn (fn () => EventLoop.draw ( drawMailbox , window , graphDrawObject - , Vector.length Constants.graphLines div 2 + , Vector.length graphLines div 2 , buttonDrawObject , 0 , triangleDrawObject