diff --git a/dot-to-dot b/dot-to-dot index e45a96b..b9f3e3a 100755 Binary files a/dot-to-dot and b/dot-to-dot differ diff --git a/dot-to-dot.mlb b/dot-to-dot.mlb index f763b46..3b02815 100644 --- a/dot-to-dot.mlb +++ b/dot-to-dot.mlb @@ -14,16 +14,11 @@ message-types/input-msg.sml message-types/draw-msg.sml functional-core/app-type.sml -ann - "allowVectorExps true" -in - functional-core/app-update.sml -end - ann "allowVectorExps true" in imperative-shell/constants.sml + functional-core/app-update.sml imperative-shell/app-draw.sml end diff --git a/functional-core/app-update.sml b/functional-core/app-update.sml index 91303c3..7665e6f 100644 --- a/functional-core/app-update.sml +++ b/functional-core/app-update.sml @@ -26,7 +26,8 @@ struct end local - val clickPoints = genClickPoints (500, 500) + val clickPoints = + genClickPoints (Constants.windowWidth, Constants.windowHeight) fun getVerticalClickPos (idx, horizontalPos, mouseX, mouseY, r, g, b) = if idx = Vector.length clickPoints then @@ -40,12 +41,14 @@ struct (idx + 1, horizontalPos, mouseX, mouseY, r, g, b) else let - val hpos = horizontalPos - 250.0 - val vpos = ~(curVerticalPos - 250.0) - val left = (hpos - 5.0) / 250.0 - val right = (hpos + 5.0) / 250.0 - val bottom = (vpos - 5.0) / 250.0 - val top = (vpos + 5.0) / 250.0 + val halfWidth = Real32.fromInt (Constants.windowWidth div 2) + val halfHeight = Real32.fromInt (Constants.windowHeight div 2) + val hpos = horizontalPos - halfWidth + val vpos = ~(curVerticalPos - halfHeight) + val left = (hpos - 5.0) / halfWidth + val right = (hpos + 5.0) / halfWidth + val bottom = (vpos - 5.0) / halfHeight + val top = (vpos + 5.0) / halfHeight in #[ left, bottom, r, g, b , right, bottom, r, g, b diff --git a/imperative-shell/constants.sml b/imperative-shell/constants.sml index 52f7eaa..355b951 100644 --- a/imperative-shell/constants.sml +++ b/imperative-shell/constants.sml @@ -1,5 +1,8 @@ structure Constants = struct + val windowWidth = 900 + val windowHeight = 900 + val graphVertexShaderString = "#version 300 es\n\ \layout (location = 0) in vec2 apos;\n\ diff --git a/imperative-shell/shell.sml b/imperative-shell/shell.sml index 9bb9907..9f957f1 100644 --- a/imperative-shell/shell.sml +++ b/imperative-shell/shell.sml @@ -9,7 +9,8 @@ struct val _ = Glfw.windowHint (Glfw.CONTEXT_VERSION_MAJOR (), 3) val _ = Glfw.windowHint (Glfw.DEPRECATED (), Glfw.FALSE ()) val _ = Glfw.windowHint (Glfw.SAMPLES (), 4) - val window = Glfw.createWindow (500, 500, "MLton - box x box") + val window = + Glfw.createWindow (Constants.windowWidth, Constants.windowHeight, "MLton - dot to dot") val _ = Glfw.makeContextCurrent window val _ = Gles3.loadGlad ()