a bit of fiddling to support different resolutions (as long as aspect ratio of window is 1:1)
This commit is contained in:
BIN
dot-to-dot
BIN
dot-to-dot
Binary file not shown.
@@ -14,16 +14,11 @@ message-types/input-msg.sml
|
|||||||
message-types/draw-msg.sml
|
message-types/draw-msg.sml
|
||||||
|
|
||||||
functional-core/app-type.sml
|
functional-core/app-type.sml
|
||||||
ann
|
|
||||||
"allowVectorExps true"
|
|
||||||
in
|
|
||||||
functional-core/app-update.sml
|
|
||||||
end
|
|
||||||
|
|
||||||
ann
|
ann
|
||||||
"allowVectorExps true"
|
"allowVectorExps true"
|
||||||
in
|
in
|
||||||
imperative-shell/constants.sml
|
imperative-shell/constants.sml
|
||||||
|
functional-core/app-update.sml
|
||||||
imperative-shell/app-draw.sml
|
imperative-shell/app-draw.sml
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ struct
|
|||||||
end
|
end
|
||||||
|
|
||||||
local
|
local
|
||||||
val clickPoints = genClickPoints (500, 500)
|
val clickPoints =
|
||||||
|
genClickPoints (Constants.windowWidth, Constants.windowHeight)
|
||||||
|
|
||||||
fun getVerticalClickPos (idx, horizontalPos, mouseX, mouseY, r, g, b) =
|
fun getVerticalClickPos (idx, horizontalPos, mouseX, mouseY, r, g, b) =
|
||||||
if idx = Vector.length clickPoints then
|
if idx = Vector.length clickPoints then
|
||||||
@@ -40,12 +41,14 @@ struct
|
|||||||
(idx + 1, horizontalPos, mouseX, mouseY, r, g, b)
|
(idx + 1, horizontalPos, mouseX, mouseY, r, g, b)
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
val hpos = horizontalPos - 250.0
|
val halfWidth = Real32.fromInt (Constants.windowWidth div 2)
|
||||||
val vpos = ~(curVerticalPos - 250.0)
|
val halfHeight = Real32.fromInt (Constants.windowHeight div 2)
|
||||||
val left = (hpos - 5.0) / 250.0
|
val hpos = horizontalPos - halfWidth
|
||||||
val right = (hpos + 5.0) / 250.0
|
val vpos = ~(curVerticalPos - halfHeight)
|
||||||
val bottom = (vpos - 5.0) / 250.0
|
val left = (hpos - 5.0) / halfWidth
|
||||||
val top = (vpos + 5.0) / 250.0
|
val right = (hpos + 5.0) / halfWidth
|
||||||
|
val bottom = (vpos - 5.0) / halfHeight
|
||||||
|
val top = (vpos + 5.0) / halfHeight
|
||||||
in
|
in
|
||||||
#[ left, bottom, r, g, b
|
#[ left, bottom, r, g, b
|
||||||
, right, bottom, r, g, b
|
, right, bottom, r, g, b
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
structure Constants =
|
structure Constants =
|
||||||
struct
|
struct
|
||||||
|
val windowWidth = 900
|
||||||
|
val windowHeight = 900
|
||||||
|
|
||||||
val graphVertexShaderString =
|
val graphVertexShaderString =
|
||||||
"#version 300 es\n\
|
"#version 300 es\n\
|
||||||
\layout (location = 0) in vec2 apos;\n\
|
\layout (location = 0) in vec2 apos;\n\
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ struct
|
|||||||
val _ = Glfw.windowHint (Glfw.CONTEXT_VERSION_MAJOR (), 3)
|
val _ = Glfw.windowHint (Glfw.CONTEXT_VERSION_MAJOR (), 3)
|
||||||
val _ = Glfw.windowHint (Glfw.DEPRECATED (), Glfw.FALSE ())
|
val _ = Glfw.windowHint (Glfw.DEPRECATED (), Glfw.FALSE ())
|
||||||
val _ = Glfw.windowHint (Glfw.SAMPLES (), 4)
|
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 _ = Glfw.makeContextCurrent window
|
||||||
val _ = Gles3.loadGlad ()
|
val _ = Gles3.loadGlad ()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user