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
functional-core/app-type.sml
imperative-shell/constants.sml
ann
"allowVectorExps true"
in
imperative-shell/app-draw.sml
imperative-shell/constants.sml
end
imperative-shell/app-draw.sml
imperative-shell/shell.sml

View File

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

View File

@@ -1,10 +1,9 @@
structure AppDraw =
structure AppDraw =
struct
type draw_object =
{ vertexBuffer: Word32.word
, vertexShader: Word32.word
, fragmentBuffer: Word32.word
, fragmentBuffer: Word32.word
, fragmentShader: Word32.word
, program: Word32.word
}
@@ -18,8 +17,7 @@ struct
val fragmentBuffer = Gles3.createBuffer ()
val fragmentShader = Gles3.createShader (Gles3.FRAGMENT_SHADER ())
val _ = Gles3.shaderSource
(fragmentShader, fragmentShaderString)
val _ = Gles3.shaderSource (fragmentShader, fragmentShaderString)
val _ = Gles3.compileShader fragmentShader
val program = Gles3.createProgram ()
@@ -35,708 +33,32 @@ struct
}
end
val graphLines =
#[
(* 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
]
fun initGraphLines () =
let
val graphDrawObject = initDrawObject
(Constants.graphVertexShaderString, Constants.graphFragmentShaderString)
val {vertexBuffer, program, ...} = graphDrawObject
val _ = Gles3.bindBuffer vertexBuffer
val _ =
Gles3.bufferData
( Constants.graphLines
, Vector.length Constants.graphLines
, Gles3.STATIC_DRAW ()
)
val _ = Gles3.vertexAttribPointer (0, 2)
val _ = Gles3.enableVertexAttribArray 0
in
graphDrawObject
end
fun drawGraphLines (graphDrawObject: draw_object) =
let
val {program, ...} = graphDrawObject
val _ = Gles3.useProgram (program)
val _ = Gles3.drawArrays
(Gles3.TRIANGLES (), 0, Vector.length Constants.graphLines div 2)
in
()
end
end

View File

@@ -15,5 +15,710 @@ struct
\void main()\n\
\{\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

View File

@@ -5,39 +5,42 @@ struct
datatype msg = KEY of int * int * int * int
fun keyCallback mailbox (key, scancode, action, mode) =
(print "hello\n";
Mailbox.send (mailbox, (KEY (key, scancode, action, mode))))
( print "hello\n"
; Mailbox.send (mailbox, (KEY (key, scancode, action, mode)))
)
fun callbackListener mailbox =
let
val _ =
case Mailbox.recv mailbox of
KEY (key, scancode, action, mode) =>
print (String.concat
[ "key: "
, Int.toString key
, " scancode: "
, Int.toString scancode
, " action: "
, Int.toString action
, " mode: "
, Int.toString mode
, "\n"
])
in
callbackListener mailbox
end
let
val _ =
case Mailbox.recv mailbox of
KEY (key, scancode, action, mode) =>
print (String.concat
[ "key: "
, Int.toString key
, " scancode: "
, Int.toString scancode
, " action: "
, Int.toString action
, " mode: "
, Int.toString mode
, "\n"
])
in
callbackListener mailbox
end
fun loop (window) =
fun loop (window, graphDrawObject) =
if not (Glfw.windowShouldClose window) then
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 _ = AppDraw.drawGraphLines graphDrawObject
val _ = Glfw.pollEvents ()
val _ = Glfw.swapBuffers window
in
loop (window)
loop (window, graphDrawObject)
end
else
Glfw.terminate ()
@@ -53,6 +56,8 @@ struct
val _ = Glfw.makeContextCurrent window
val _ = Gles3.loadGlad ()
val graphDrawObject = AppDraw.initGraphLines ()
val inputMailbox = Mailbox.mailbox ()
(* Set callback sender *)
val _ = CML.spawn (fn () =>
@@ -66,7 +71,7 @@ struct
(* Set callback listener *)
val _ = CML.spawn (fn () => callbackListener inputMailbox)
in
loop (window)
loop (window, graphDrawObject)
end
end