a bit of refactoring (move 'graphLines' constant vector to imperative-shell/constants.sml), and get graphLines background drawn to the screen

This commit is contained in:
2024-07-30 11:17:19 +01:00
parent d726823249
commit 75b82fd888
6 changed files with 768 additions and 736 deletions

Binary file not shown.

View File

@@ -11,12 +11,12 @@ in
end end
functional-core/app-type.sml functional-core/app-type.sml
imperative-shell/constants.sml
ann ann
"allowVectorExps true" "allowVectorExps true"
in in
imperative-shell/app-draw.sml imperative-shell/constants.sml
end end
imperative-shell/app-draw.sml
imperative-shell/shell.sml imperative-shell/shell.sml

View File

@@ -35,7 +35,7 @@ struct
| [] => acc | [] => acc
in in
fun getTrianglesVector (app: app_type) = fun getTrianglesVector (app: app_type) =
let val lst = helpGetTrianglseVector (#triangles app, []) let val lst = helpGetTrianglesVector (#triangles app, [])
in Vector.concat lst in Vector.concat lst
end end
end end

View File

@@ -4,7 +4,6 @@ struct
{ vertexBuffer: Word32.word { vertexBuffer: Word32.word
, vertexShader: Word32.word , vertexShader: Word32.word
, fragmentBuffer: Word32.word , fragmentBuffer: Word32.word
, fragmentBuffer: Word32.word
, fragmentShader: Word32.word , fragmentShader: Word32.word
, program: Word32.word , program: Word32.word
} }
@@ -18,8 +17,7 @@ struct
val fragmentBuffer = Gles3.createBuffer () val fragmentBuffer = Gles3.createBuffer ()
val fragmentShader = Gles3.createShader (Gles3.FRAGMENT_SHADER ()) val fragmentShader = Gles3.createShader (Gles3.FRAGMENT_SHADER ())
val _ = Gles3.shaderSource val _ = Gles3.shaderSource (fragmentShader, fragmentShaderString)
(fragmentShader, fragmentShaderString)
val _ = Gles3.compileShader fragmentShader val _ = Gles3.compileShader fragmentShader
val program = Gles3.createProgram () val program = Gles3.createProgram ()
@@ -35,708 +33,32 @@ struct
} }
end end
val graphLines = fun initGraphLines () =
#[ let
(* x = ~0.95 *) val graphDrawObject = initDrawObject
~0.949, ~1.0, (Constants.graphVertexShaderString, Constants.graphFragmentShaderString)
~0.951, ~1.0, val {vertexBuffer, program, ...} = graphDrawObject
~0.951, 1.0,
val _ = Gles3.bindBuffer vertexBuffer
~0.951, 1.0, val _ =
~0.949, 1.0, Gles3.bufferData
~0.949, ~1.0, ( Constants.graphLines
, Vector.length Constants.graphLines
(* x = ~0.9 *) , Gles3.STATIC_DRAW ()
~0.898, ~1.0, )
~0.902, ~1.0, val _ = Gles3.vertexAttribPointer (0, 2)
~0.902, 1.0, val _ = Gles3.enableVertexAttribArray 0
in
~0.902, 1.0, graphDrawObject
~0.898, 1.0, end
~0.898, ~1.0,
fun drawGraphLines (graphDrawObject: draw_object) =
(* x = ~0.85 *) let
~0.849, ~1.0, val {program, ...} = graphDrawObject
~0.851, ~1.0, val _ = Gles3.useProgram (program)
~0.851, 1.0, val _ = Gles3.drawArrays
(Gles3.TRIANGLES (), 0, Vector.length Constants.graphLines div 2)
~0.851, 1.0, in
~0.849, 1.0, ()
~0.849, ~1.0, end
(* x = ~0.8 *)
~0.798, ~1.0,
~0.802, ~1.0,
~0.802, 1.0,
~0.802, 1.0,
~0.798, 1.0,
~0.798, ~1.0,
(* x = ~0.75 *)
~0.749, ~1.0,
~0.751, ~1.0,
~0.751, 1.0,
~0.751, 1.0,
~0.749, 1.0,
~0.749, ~1.0,
(* x = ~0.7 *)
~0.698, ~1.0,
~0.702, ~1.0,
~0.702, 1.0,
~0.702, 1.0,
~0.698, 1.0,
~0.698, ~1.0,
(* x = ~0.65 *)
~0.649, ~1.0,
~0.651, ~1.0,
~0.651, 1.0,
~0.651, 1.0,
~0.649, 1.0,
~0.649, ~1.0,
(* x = ~0.6 *)
~0.598, ~1.0,
~0.602, ~1.0,
~0.602, 1.0,
~0.602, 1.0,
~0.598, 1.0,
~0.598, ~1.0,
(* x = ~0.55 *)
~0.549, ~1.0,
~0.551, ~1.0,
~0.551, 1.0,
~0.551, 1.0,
~0.549, 1.0,
~0.549, ~1.0,
(* x = ~0.5 *)
~0.498, ~1.0,
~0.502, ~1.0,
~0.502, 1.0,
~0.502, 1.0,
~0.498, 1.0,
~0.498, ~1.0,
(* x = ~0.45 *)
~0.449, ~1.0,
~0.451, ~1.0,
~0.451, 1.0,
~0.451, 1.0,
~0.449, 1.0,
~0.449, ~1.0,
(* x = ~0.4 *)
~0.398, ~1.0,
~0.402, ~1.0,
~0.402, 1.0,
~0.402, 1.0,
~0.398, 1.0,
~0.398, ~1.0,
(* x = ~0.35 *)
~0.349, ~1.0,
~0.351, ~1.0,
~0.351, 1.0,
~0.351, 1.0,
~0.349, 1.0,
~0.349, ~1.0,
(* x = ~0.3 *)
~0.298, ~1.0,
~0.302, ~1.0,
~0.302, 1.0,
~0.302, 1.0,
~0.298, 1.0,
~0.298, ~1.0,
(* x = ~0.25 *)
~0.249, ~1.0,
~0.251, ~1.0,
~0.251, 1.0,
~0.251, 1.0,
~0.249, 1.0,
~0.249, ~1.0,
(* x = ~0.2 *)
~0.198, ~1.0,
~0.202, ~1.0,
~0.202, 1.0,
~0.202, 1.0,
~0.198, 1.0,
~0.198, ~1.0,
(* x = ~0.15 *)
~0.149, ~1.0,
~0.151, ~1.0,
~0.151, 1.0,
~0.151, 1.0,
~0.149, 1.0,
~0.149, ~1.0,
(* x = ~0.1 *)
~0.098, ~1.0,
~0.102, ~1.0,
~0.102, 1.0,
~0.102, 1.0,
~0.098, 1.0,
~0.098, ~1.0,
(* x = ~0.05 *)
~0.049, ~1.0,
~0.051, ~1.0,
~0.051, 1.0,
~0.051, 1.0,
~0.049, 1.0,
~0.049, ~1.0,
(* x = 0.0 *)
~0.002, ~1.0,
0.002, ~1.0,
0.002, 1.0,
0.002, 1.0,
~0.002, 1.0,
~0.002, ~1.0,
(* x = 0.05 *)
0.049, ~1.0,
0.051, ~1.0,
0.051, 1.0,
0.051, 1.0,
0.049, 1.0,
0.049, ~1.0,
(* x = 0.0 *)
0.098, ~1.0,
0.102, ~1.0,
0.102, 1.0,
0.102, 1.0,
0.098, 1.0,
0.098, ~1.0,
(* x = 0.15 *)
0.149, ~1.0,
0.151, ~1.0,
0.151, 1.0,
0.151, 1.0,
0.149, 1.0,
0.149, ~1.0,
(* x = 0.2 *)
0.198, ~1.0,
0.202, ~1.0,
0.202, 1.0,
0.202, 1.0,
0.198, 1.0,
0.198, ~1.0,
(* x = 0.25 *)
0.249, ~1.0,
0.251, ~1.0,
0.251, 1.0,
0.251, 1.0,
0.249, 1.0,
0.249, ~1.0,
(* x = 0.3 *)
0.298, ~1.0,
0.302, ~1.0,
0.302, 1.0,
0.302, 1.0,
0.298, 1.0,
0.298, ~1.0,
(* x = 0.35 *)
0.349, ~1.0,
0.351, ~1.0,
0.351, 1.0,
0.351, 1.0,
0.349, 1.0,
0.349, ~1.0,
(* x = 0.4 *)
0.398, ~1.0,
0.402, ~1.0,
0.402, 1.0,
0.402, 1.0,
0.398, 1.0,
0.398, ~1.0,
(* x = 0.45 *)
0.449, ~1.0,
0.451, ~1.0,
0.451, 1.0,
0.451, 1.0,
0.449, 1.0,
0.449, ~1.0,
(* x = 0.5 *)
0.498, ~1.0,
0.502, ~1.0,
0.502, 1.0,
0.502, 1.0,
0.498, 1.0,
0.498, ~1.0,
(* x = 0.55 *)
0.549, ~1.0,
0.551, ~1.0,
0.551, 1.0,
0.551, 1.0,
0.549, 1.0,
0.549, ~1.0,
(* x = 0.6 *)
0.598, ~1.0,
0.602, ~1.0,
0.602, 1.0,
0.602, 1.0,
0.598, 1.0,
0.598, ~1.0,
(* x = 0.65 *)
0.649, ~1.0,
0.651, ~1.0,
0.651, 1.0,
0.651, 1.0,
0.649, 1.0,
0.649, ~1.0,
(* x = 0.7 *)
0.698, ~1.0,
0.702, ~1.0,
0.702, 1.0,
0.702, 1.0,
0.698, 1.0,
0.698, ~1.0,
(* x = 0.75 *)
0.749, ~1.0,
0.751, ~1.0,
0.751, 1.0,
0.751, 1.0,
0.749, 1.0,
0.749, ~1.0,
(* x = 0.8 *)
0.798, ~1.0,
0.802, ~1.0,
0.802, 1.0,
0.802, 1.0,
0.798, 1.0,
0.798, ~1.0,
(* x = 0.85 *)
0.849, ~1.0,
0.851, ~1.0,
0.851, 1.0,
0.851, 1.0,
0.849, 1.0,
0.849, ~1.0,
(* x = 0.9 *)
0.898, ~1.0,
0.902, ~1.0,
0.902, 1.0,
0.902, 1.0,
0.898, 1.0,
0.898, ~1.0,
(* x = 0.95 *)
0.949, ~1.0,
0.951, ~1.0,
0.951, 1.0,
0.951, 1.0,
0.949, 1.0,
0.949, ~1.0,
(* y = ~0.95 *)
~1.0, ~0.949,
~1.0, ~0.951,
1.0, ~0.951,
1.0, ~0.951,
1.0, ~0.949,
~1.0, ~0.949,
(* y = ~0.9 *)
~1.0, ~0.898,
~1.0, ~0.902,
1.0, ~0.902,
1.0, ~0.902,
1.0, ~0.898,
~1.0, ~0.898,
(* y = ~0.85 *)
~1.0, ~0.849,
~1.0, ~0.851,
1.0, ~0.851,
1.0, ~0.851,
1.0, ~0.849,
~1.0, ~0.849,
(* y = ~0.8 *)
~1.0, ~0.798,
~1.0, ~0.802,
1.0, ~0.802,
1.0, ~0.802,
1.0, ~0.798,
~1.0, ~0.798,
(* y = ~0.75 *)
~1.0, ~0.749,
~1.0, ~0.751,
1.0, ~0.751,
1.0, ~0.751,
1.0, ~0.749,
~1.0, ~0.749,
(* y = ~0.7 *)
~1.0, ~0.698,
~1.0, ~0.702,
1.0, ~0.702,
1.0, ~0.702,
1.0, ~0.698,
~1.0, ~0.698,
(* y = ~0.65 *)
~1.0, ~0.649,
~1.0, ~0.651,
1.0, ~0.651,
1.0, ~0.651,
1.0, ~0.649,
~1.0, ~0.649,
(* y = ~0.6 *)
~1.0, ~0.598,
~1.0, ~0.602,
1.0, ~0.602,
1.0, ~0.602,
1.0, ~0.598,
~1.0, ~0.598,
(* y = ~0.55 *)
~1.0, ~0.549,
~1.0, ~0.551,
1.0, ~0.551,
1.0, ~0.551,
1.0, ~0.549,
~1.0, ~0.549,
(* y = ~0.5 *)
~1.0, ~0.498,
~1.0, ~0.502,
1.0, ~0.502,
1.0, ~0.502,
1.0, ~0.498,
~1.0, ~0.498,
(* y = ~0.45 *)
~1.0, ~0.449,
~1.0, ~0.451,
1.0, ~0.451,
1.0, ~0.451,
1.0, ~0.449,
~1.0, ~0.449,
(* y = ~0.4 *)
~1.0, ~0.398,
~1.0, ~0.402,
1.0, ~0.402,
1.0, ~0.402,
1.0, ~0.398,
~1.0, ~0.398,
(* y = ~0.35 *)
~1.0, ~0.349,
~1.0, ~0.351,
1.0, ~0.351,
1.0, ~0.351,
1.0, ~0.349,
~1.0, ~0.349,
(* y = ~0.3 *)
~1.0, ~0.298,
~1.0, ~0.302,
1.0, ~0.302,
1.0, ~0.302,
1.0, ~0.298,
~1.0, ~0.298,
(* y = ~0.25 *)
~1.0, ~0.249,
~1.0, ~0.251,
1.0, ~0.251,
1.0, ~0.251,
1.0, ~0.249,
~1.0, ~0.249,
(* y = ~0.2 *)
~1.0, ~0.198,
~1.0, ~0.202,
1.0, ~0.202,
1.0, ~0.202,
1.0, ~0.198,
~1.0, ~0.198,
(* y = ~0.15 *)
~1.0, ~0.149,
~1.0, ~0.151,
1.0, ~0.151,
1.0, ~0.151,
1.0, ~0.149,
~1.0, ~0.149,
(* y = ~0.1 *)
~1.0, ~0.098,
~1.0, ~0.102,
1.0, ~0.102,
1.0, ~0.102,
1.0, ~0.098,
~1.0, ~0.098,
(* y = ~0.05 *)
~1.0, ~0.049,
~1.0, ~0.051,
1.0, ~0.051,
1.0, ~0.051,
1.0, ~0.049,
~1.0, ~0.049,
(* y = 0.0 *)
~1.0, ~0.002,
~1.0, 0.002,
1.0, 0.002,
1.0, 0.002,
1.0, ~0.002,
~1.0, ~0.002,
(* y = 0.05 *)
~1.0, 0.049,
~1.0, 0.051,
1.0, 0.051,
1.0, 0.051,
1.0, 0.049,
~1.0, 0.049,
(* y = 0.0 *)
~1.0, 0.098,
~1.0, 0.102,
1.0, 0.102,
1.0, 0.102,
1.0, 0.098,
~1.0, 0.098,
(* y = 0.15 *)
~1.0, 0.149,
~1.0, 0.151,
1.0, 0.151,
1.0, 0.151,
1.0, 0.149,
~1.0, 0.149,
(* y = 0.2 *)
~1.0, 0.198,
~1.0, 0.202,
1.0, 0.202,
1.0, 0.202,
1.0, 0.198,
~1.0, 0.198,
(* y = 0.25 *)
~1.0, 0.249,
~1.0, 0.251,
1.0, 0.251,
1.0, 0.251,
1.0, 0.249,
~1.0, 0.249,
(* y = 0.3 *)
~1.0, 0.298,
~1.0, 0.302,
1.0, 0.302,
1.0, 0.302,
1.0, 0.298,
~1.0, 0.298,
(* y = 0.35 *)
~1.0, 0.349,
~1.0, 0.351,
1.0, 0.351,
1.0, 0.351,
1.0, 0.349,
~1.0, 0.349,
(* y = 0.4 *)
~1.0, 0.398,
~1.0, 0.402,
1.0, 0.402,
1.0, 0.402,
1.0, 0.398,
~1.0, 0.398,
(* y = 0.45 *)
~1.0, 0.449,
~1.0, 0.451,
1.0, 0.451,
1.0, 0.451,
1.0, 0.449,
~1.0, 0.449,
(* y = 0.5 *)
~1.0, 0.498,
~1.0, 0.502,
1.0, 0.502,
1.0, 0.502,
1.0, 0.498,
~1.0, 0.498,
(* y = 0.55 *)
~1.0, 0.549,
~1.0, 0.551,
1.0, 0.551,
1.0, 0.551,
1.0, 0.549,
~1.0, 0.549,
(* y = 0.6 *)
~1.0, 0.598,
~1.0, 0.602,
1.0, 0.602,
1.0, 0.602,
1.0, 0.598,
~1.0, 0.598,
(* y = 0.65 *)
~1.0, 0.649,
~1.0, 0.651,
1.0, 0.651,
1.0, 0.651,
1.0, 0.649,
~1.0, 0.649,
(* y = 0.7 *)
~1.0, 0.698,
~1.0, 0.702,
1.0, 0.702,
1.0, 0.702,
1.0, 0.698,
~1.0, 0.698,
(* y = 0.75 *)
~1.0, 0.749,
~1.0, 0.751,
1.0, 0.751,
1.0, 0.751,
1.0, 0.749,
~1.0, 0.749,
(* y = 0.8 *)
~1.0, 0.798,
~1.0, 0.802,
1.0, 0.802,
1.0, 0.802,
1.0, 0.798,
~1.0, 0.798,
(* y = 0.85 *)
~1.0, 0.849,
~1.0, 0.851,
1.0, 0.851,
1.0, 0.851,
1.0, 0.849,
~1.0, 0.849,
(* y = 0.9 *)
~1.0, 0.898,
~1.0, 0.902,
1.0, 0.902,
1.0, 0.902,
1.0, 0.898,
~1.0, 0.898,
(* y = 0.95 *)
~1.0, 0.949,
~1.0, 0.951,
1.0, 0.951,
1.0, 0.951,
1.0, 0.949,
~1.0, 0.949
]
end end

View File

@@ -15,5 +15,710 @@ struct
\void main()\n\ \void main()\n\
\{\n\ \{\n\
\ FragColor = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n\ \ FragColor = vec4(0.0f, 0.0f, 0.0f, 1.0f);\n\
\}"; \}"
val graphLines: Real32.real vector =
#[
(* x = ~0.95 *)
~0.949, ~1.0,
~0.951, ~1.0,
~0.951, 1.0,
~0.951, 1.0,
~0.949, 1.0,
~0.949, ~1.0,
(* x = ~0.9 *)
~0.898, ~1.0,
~0.902, ~1.0,
~0.902, 1.0,
~0.902, 1.0,
~0.898, 1.0,
~0.898, ~1.0,
(* x = ~0.85 *)
~0.849, ~1.0,
~0.851, ~1.0,
~0.851, 1.0,
~0.851, 1.0,
~0.849, 1.0,
~0.849, ~1.0,
(* x = ~0.8 *)
~0.798, ~1.0,
~0.802, ~1.0,
~0.802, 1.0,
~0.802, 1.0,
~0.798, 1.0,
~0.798, ~1.0,
(* x = ~0.75 *)
~0.749, ~1.0,
~0.751, ~1.0,
~0.751, 1.0,
~0.751, 1.0,
~0.749, 1.0,
~0.749, ~1.0,
(* x = ~0.7 *)
~0.698, ~1.0,
~0.702, ~1.0,
~0.702, 1.0,
~0.702, 1.0,
~0.698, 1.0,
~0.698, ~1.0,
(* x = ~0.65 *)
~0.649, ~1.0,
~0.651, ~1.0,
~0.651, 1.0,
~0.651, 1.0,
~0.649, 1.0,
~0.649, ~1.0,
(* x = ~0.6 *)
~0.598, ~1.0,
~0.602, ~1.0,
~0.602, 1.0,
~0.602, 1.0,
~0.598, 1.0,
~0.598, ~1.0,
(* x = ~0.55 *)
~0.549, ~1.0,
~0.551, ~1.0,
~0.551, 1.0,
~0.551, 1.0,
~0.549, 1.0,
~0.549, ~1.0,
(* x = ~0.5 *)
~0.498, ~1.0,
~0.502, ~1.0,
~0.502, 1.0,
~0.502, 1.0,
~0.498, 1.0,
~0.498, ~1.0,
(* x = ~0.45 *)
~0.449, ~1.0,
~0.451, ~1.0,
~0.451, 1.0,
~0.451, 1.0,
~0.449, 1.0,
~0.449, ~1.0,
(* x = ~0.4 *)
~0.398, ~1.0,
~0.402, ~1.0,
~0.402, 1.0,
~0.402, 1.0,
~0.398, 1.0,
~0.398, ~1.0,
(* x = ~0.35 *)
~0.349, ~1.0,
~0.351, ~1.0,
~0.351, 1.0,
~0.351, 1.0,
~0.349, 1.0,
~0.349, ~1.0,
(* x = ~0.3 *)
~0.298, ~1.0,
~0.302, ~1.0,
~0.302, 1.0,
~0.302, 1.0,
~0.298, 1.0,
~0.298, ~1.0,
(* x = ~0.25 *)
~0.249, ~1.0,
~0.251, ~1.0,
~0.251, 1.0,
~0.251, 1.0,
~0.249, 1.0,
~0.249, ~1.0,
(* x = ~0.2 *)
~0.198, ~1.0,
~0.202, ~1.0,
~0.202, 1.0,
~0.202, 1.0,
~0.198, 1.0,
~0.198, ~1.0,
(* x = ~0.15 *)
~0.149, ~1.0,
~0.151, ~1.0,
~0.151, 1.0,
~0.151, 1.0,
~0.149, 1.0,
~0.149, ~1.0,
(* x = ~0.1 *)
~0.098, ~1.0,
~0.102, ~1.0,
~0.102, 1.0,
~0.102, 1.0,
~0.098, 1.0,
~0.098, ~1.0,
(* x = ~0.05 *)
~0.049, ~1.0,
~0.051, ~1.0,
~0.051, 1.0,
~0.051, 1.0,
~0.049, 1.0,
~0.049, ~1.0,
(* x = 0.0 *)
~0.002, ~1.0,
0.002, ~1.0,
0.002, 1.0,
0.002, 1.0,
~0.002, 1.0,
~0.002, ~1.0,
(* x = 0.05 *)
0.049, ~1.0,
0.051, ~1.0,
0.051, 1.0,
0.051, 1.0,
0.049, 1.0,
0.049, ~1.0,
(* x = 0.0 *)
0.098, ~1.0,
0.102, ~1.0,
0.102, 1.0,
0.102, 1.0,
0.098, 1.0,
0.098, ~1.0,
(* x = 0.15 *)
0.149, ~1.0,
0.151, ~1.0,
0.151, 1.0,
0.151, 1.0,
0.149, 1.0,
0.149, ~1.0,
(* x = 0.2 *)
0.198, ~1.0,
0.202, ~1.0,
0.202, 1.0,
0.202, 1.0,
0.198, 1.0,
0.198, ~1.0,
(* x = 0.25 *)
0.249, ~1.0,
0.251, ~1.0,
0.251, 1.0,
0.251, 1.0,
0.249, 1.0,
0.249, ~1.0,
(* x = 0.3 *)
0.298, ~1.0,
0.302, ~1.0,
0.302, 1.0,
0.302, 1.0,
0.298, 1.0,
0.298, ~1.0,
(* x = 0.35 *)
0.349, ~1.0,
0.351, ~1.0,
0.351, 1.0,
0.351, 1.0,
0.349, 1.0,
0.349, ~1.0,
(* x = 0.4 *)
0.398, ~1.0,
0.402, ~1.0,
0.402, 1.0,
0.402, 1.0,
0.398, 1.0,
0.398, ~1.0,
(* x = 0.45 *)
0.449, ~1.0,
0.451, ~1.0,
0.451, 1.0,
0.451, 1.0,
0.449, 1.0,
0.449, ~1.0,
(* x = 0.5 *)
0.498, ~1.0,
0.502, ~1.0,
0.502, 1.0,
0.502, 1.0,
0.498, 1.0,
0.498, ~1.0,
(* x = 0.55 *)
0.549, ~1.0,
0.551, ~1.0,
0.551, 1.0,
0.551, 1.0,
0.549, 1.0,
0.549, ~1.0,
(* x = 0.6 *)
0.598, ~1.0,
0.602, ~1.0,
0.602, 1.0,
0.602, 1.0,
0.598, 1.0,
0.598, ~1.0,
(* x = 0.65 *)
0.649, ~1.0,
0.651, ~1.0,
0.651, 1.0,
0.651, 1.0,
0.649, 1.0,
0.649, ~1.0,
(* x = 0.7 *)
0.698, ~1.0,
0.702, ~1.0,
0.702, 1.0,
0.702, 1.0,
0.698, 1.0,
0.698, ~1.0,
(* x = 0.75 *)
0.749, ~1.0,
0.751, ~1.0,
0.751, 1.0,
0.751, 1.0,
0.749, 1.0,
0.749, ~1.0,
(* x = 0.8 *)
0.798, ~1.0,
0.802, ~1.0,
0.802, 1.0,
0.802, 1.0,
0.798, 1.0,
0.798, ~1.0,
(* x = 0.85 *)
0.849, ~1.0,
0.851, ~1.0,
0.851, 1.0,
0.851, 1.0,
0.849, 1.0,
0.849, ~1.0,
(* x = 0.9 *)
0.898, ~1.0,
0.902, ~1.0,
0.902, 1.0,
0.902, 1.0,
0.898, 1.0,
0.898, ~1.0,
(* x = 0.95 *)
0.949, ~1.0,
0.951, ~1.0,
0.951, 1.0,
0.951, 1.0,
0.949, 1.0,
0.949, ~1.0,
(* y = ~0.95 *)
~1.0, ~0.949,
~1.0, ~0.951,
1.0, ~0.951,
1.0, ~0.951,
1.0, ~0.949,
~1.0, ~0.949,
(* y = ~0.9 *)
~1.0, ~0.898,
~1.0, ~0.902,
1.0, ~0.902,
1.0, ~0.902,
1.0, ~0.898,
~1.0, ~0.898,
(* y = ~0.85 *)
~1.0, ~0.849,
~1.0, ~0.851,
1.0, ~0.851,
1.0, ~0.851,
1.0, ~0.849,
~1.0, ~0.849,
(* y = ~0.8 *)
~1.0, ~0.798,
~1.0, ~0.802,
1.0, ~0.802,
1.0, ~0.802,
1.0, ~0.798,
~1.0, ~0.798,
(* y = ~0.75 *)
~1.0, ~0.749,
~1.0, ~0.751,
1.0, ~0.751,
1.0, ~0.751,
1.0, ~0.749,
~1.0, ~0.749,
(* y = ~0.7 *)
~1.0, ~0.698,
~1.0, ~0.702,
1.0, ~0.702,
1.0, ~0.702,
1.0, ~0.698,
~1.0, ~0.698,
(* y = ~0.65 *)
~1.0, ~0.649,
~1.0, ~0.651,
1.0, ~0.651,
1.0, ~0.651,
1.0, ~0.649,
~1.0, ~0.649,
(* y = ~0.6 *)
~1.0, ~0.598,
~1.0, ~0.602,
1.0, ~0.602,
1.0, ~0.602,
1.0, ~0.598,
~1.0, ~0.598,
(* y = ~0.55 *)
~1.0, ~0.549,
~1.0, ~0.551,
1.0, ~0.551,
1.0, ~0.551,
1.0, ~0.549,
~1.0, ~0.549,
(* y = ~0.5 *)
~1.0, ~0.498,
~1.0, ~0.502,
1.0, ~0.502,
1.0, ~0.502,
1.0, ~0.498,
~1.0, ~0.498,
(* y = ~0.45 *)
~1.0, ~0.449,
~1.0, ~0.451,
1.0, ~0.451,
1.0, ~0.451,
1.0, ~0.449,
~1.0, ~0.449,
(* y = ~0.4 *)
~1.0, ~0.398,
~1.0, ~0.402,
1.0, ~0.402,
1.0, ~0.402,
1.0, ~0.398,
~1.0, ~0.398,
(* y = ~0.35 *)
~1.0, ~0.349,
~1.0, ~0.351,
1.0, ~0.351,
1.0, ~0.351,
1.0, ~0.349,
~1.0, ~0.349,
(* y = ~0.3 *)
~1.0, ~0.298,
~1.0, ~0.302,
1.0, ~0.302,
1.0, ~0.302,
1.0, ~0.298,
~1.0, ~0.298,
(* y = ~0.25 *)
~1.0, ~0.249,
~1.0, ~0.251,
1.0, ~0.251,
1.0, ~0.251,
1.0, ~0.249,
~1.0, ~0.249,
(* y = ~0.2 *)
~1.0, ~0.198,
~1.0, ~0.202,
1.0, ~0.202,
1.0, ~0.202,
1.0, ~0.198,
~1.0, ~0.198,
(* y = ~0.15 *)
~1.0, ~0.149,
~1.0, ~0.151,
1.0, ~0.151,
1.0, ~0.151,
1.0, ~0.149,
~1.0, ~0.149,
(* y = ~0.1 *)
~1.0, ~0.098,
~1.0, ~0.102,
1.0, ~0.102,
1.0, ~0.102,
1.0, ~0.098,
~1.0, ~0.098,
(* y = ~0.05 *)
~1.0, ~0.049,
~1.0, ~0.051,
1.0, ~0.051,
1.0, ~0.051,
1.0, ~0.049,
~1.0, ~0.049,
(* y = 0.0 *)
~1.0, ~0.002,
~1.0, 0.002,
1.0, 0.002,
1.0, 0.002,
1.0, ~0.002,
~1.0, ~0.002,
(* y = 0.05 *)
~1.0, 0.049,
~1.0, 0.051,
1.0, 0.051,
1.0, 0.051,
1.0, 0.049,
~1.0, 0.049,
(* y = 0.0 *)
~1.0, 0.098,
~1.0, 0.102,
1.0, 0.102,
1.0, 0.102,
1.0, 0.098,
~1.0, 0.098,
(* y = 0.15 *)
~1.0, 0.149,
~1.0, 0.151,
1.0, 0.151,
1.0, 0.151,
1.0, 0.149,
~1.0, 0.149,
(* y = 0.2 *)
~1.0, 0.198,
~1.0, 0.202,
1.0, 0.202,
1.0, 0.202,
1.0, 0.198,
~1.0, 0.198,
(* y = 0.25 *)
~1.0, 0.249,
~1.0, 0.251,
1.0, 0.251,
1.0, 0.251,
1.0, 0.249,
~1.0, 0.249,
(* y = 0.3 *)
~1.0, 0.298,
~1.0, 0.302,
1.0, 0.302,
1.0, 0.302,
1.0, 0.298,
~1.0, 0.298,
(* y = 0.35 *)
~1.0, 0.349,
~1.0, 0.351,
1.0, 0.351,
1.0, 0.351,
1.0, 0.349,
~1.0, 0.349,
(* y = 0.4 *)
~1.0, 0.398,
~1.0, 0.402,
1.0, 0.402,
1.0, 0.402,
1.0, 0.398,
~1.0, 0.398,
(* y = 0.45 *)
~1.0, 0.449,
~1.0, 0.451,
1.0, 0.451,
1.0, 0.451,
1.0, 0.449,
~1.0, 0.449,
(* y = 0.5 *)
~1.0, 0.498,
~1.0, 0.502,
1.0, 0.502,
1.0, 0.502,
1.0, 0.498,
~1.0, 0.498,
(* y = 0.55 *)
~1.0, 0.549,
~1.0, 0.551,
1.0, 0.551,
1.0, 0.551,
1.0, 0.549,
~1.0, 0.549,
(* y = 0.6 *)
~1.0, 0.598,
~1.0, 0.602,
1.0, 0.602,
1.0, 0.602,
1.0, 0.598,
~1.0, 0.598,
(* y = 0.65 *)
~1.0, 0.649,
~1.0, 0.651,
1.0, 0.651,
1.0, 0.651,
1.0, 0.649,
~1.0, 0.649,
(* y = 0.7 *)
~1.0, 0.698,
~1.0, 0.702,
1.0, 0.702,
1.0, 0.702,
1.0, 0.698,
~1.0, 0.698,
(* y = 0.75 *)
~1.0, 0.749,
~1.0, 0.751,
1.0, 0.751,
1.0, 0.751,
1.0, 0.749,
~1.0, 0.749,
(* y = 0.8 *)
~1.0, 0.798,
~1.0, 0.802,
1.0, 0.802,
1.0, 0.802,
1.0, 0.798,
~1.0, 0.798,
(* y = 0.85 *)
~1.0, 0.849,
~1.0, 0.851,
1.0, 0.851,
1.0, 0.851,
1.0, 0.849,
~1.0, 0.849,
(* y = 0.9 *)
~1.0, 0.898,
~1.0, 0.902,
1.0, 0.902,
1.0, 0.902,
1.0, 0.898,
~1.0, 0.898,
(* y = 0.95 *)
~1.0, 0.949,
~1.0, 0.951,
1.0, 0.951,
1.0, 0.951,
1.0, 0.949,
~1.0, 0.949
]
end end

View File

@@ -5,8 +5,9 @@ struct
datatype msg = KEY of int * int * int * int datatype msg = KEY of int * int * int * int
fun keyCallback mailbox (key, scancode, action, mode) = fun keyCallback mailbox (key, scancode, action, mode) =
(print "hello\n"; ( print "hello\n"
Mailbox.send (mailbox, (KEY (key, scancode, action, mode)))) ; Mailbox.send (mailbox, (KEY (key, scancode, action, mode)))
)
fun callbackListener mailbox = fun callbackListener mailbox =
let let
@@ -28,16 +29,18 @@ struct
callbackListener mailbox callbackListener mailbox
end end
fun loop (window) = fun loop (window, graphDrawObject) =
if not (Glfw.windowShouldClose window) then if not (Glfw.windowShouldClose window) then
let let
val _ = Gles3.clearColor (0.1, 0.1, 0.1, 0.1) val _ = Gles3.clearColor (1.0, 1.0, 1.0, 1.0)
val _ = Gles3.clear () val _ = Gles3.clear ()
val _ = AppDraw.drawGraphLines graphDrawObject
val _ = Glfw.pollEvents () val _ = Glfw.pollEvents ()
val _ = Glfw.swapBuffers window val _ = Glfw.swapBuffers window
in in
loop (window) loop (window, graphDrawObject)
end end
else else
Glfw.terminate () Glfw.terminate ()
@@ -53,6 +56,8 @@ struct
val _ = Glfw.makeContextCurrent window val _ = Glfw.makeContextCurrent window
val _ = Gles3.loadGlad () val _ = Gles3.loadGlad ()
val graphDrawObject = AppDraw.initGraphLines ()
val inputMailbox = Mailbox.mailbox () val inputMailbox = Mailbox.mailbox ()
(* Set callback sender *) (* Set callback sender *)
val _ = CML.spawn (fn () => val _ = CML.spawn (fn () =>
@@ -66,7 +71,7 @@ struct
(* Set callback listener *) (* Set callback listener *)
val _ = CML.spawn (fn () => callbackListener inputMailbox) val _ = CML.spawn (fn () => callbackListener inputMailbox)
in in
loop (window) loop (window, graphDrawObject)
end end
end end