diff --git a/dot-to-dot b/dot-to-dot index 1e3f27b..f392f5b 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 7f51bfe..56c2ac2 100644 --- a/dot-to-dot.mlb +++ b/dot-to-dot.mlb @@ -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 diff --git a/functional-core/app-type.sml b/functional-core/app-type.sml index ecb7524..1cf2e9f 100644 --- a/functional-core/app-type.sml +++ b/functional-core/app-type.sml @@ -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 diff --git a/imperative-shell/app-draw.sml b/imperative-shell/app-draw.sml index fc4cc9a..bafdc20 100644 --- a/imperative-shell/app-draw.sml +++ b/imperative-shell/app-draw.sml @@ -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 diff --git a/imperative-shell/constants.sml b/imperative-shell/constants.sml index 0ea1c43..0068c1e 100644 --- a/imperative-shell/constants.sml +++ b/imperative-shell/constants.sml @@ -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 diff --git a/imperative-shell/shell.sml b/imperative-shell/shell.sml index fbf5c80..17edf32 100644 --- a/imperative-shell/shell.sml +++ b/imperative-shell/shell.sml @@ -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