refactor to allow graph lines to be shown at start up

This commit is contained in:
2024-08-03 06:05:26 +01:00
parent ee2274ffbc
commit 0d1ea9444b
6 changed files with 27 additions and 14 deletions

View File

@@ -41,11 +41,7 @@ struct
val _ = Gles3.bindBuffer vertexBuffer
val _ =
Gles3.bufferData
( Constants.graphLines
, Vector.length Constants.graphLines
, Gles3.STATIC_DRAW ()
)
Gles3.bufferData (#[], 0, Gles3.STATIC_DRAW ())
val _ = Gles3.vertexAttribPointer (0, 2, 2, 0)
val _ = Gles3.enableVertexAttribArray 0
in

View File

@@ -40,9 +40,4 @@ struct
\{\n\
\ FragColor = vec4(frag_col.x, frag_col.y, frag_col.z, 1.0f);\n\
\}"
(* Todo: fix. Currently an empty vector which is not desired result,
* but changing vector dynamically (through resizing) works as desired. *)
val graphLines: Real32.real vector =
Vector.fromList []
end

View File

@@ -14,7 +14,7 @@ struct
loop (inputMailbox, drawMailbox, mouseX, mouseY, model)
end
in
fun update (inputMailbox, drawMailbox) =
fun update (inputMailbox, drawMailbox, initial) =
loop
( inputMailbox
, drawMailbox

View File

@@ -15,7 +15,13 @@ struct
val _ = Glfw.makeContextCurrent window
val _ = Gles3.loadGlad ()
val initialModel = AppType.getInitial (Constants.windowWidth, Constants.windowHeight)
val graphLines = #graphLines initialModel
val graphDrawObject = AppDraw.initGraphLines ()
val _ =
AppDraw.uploadGraphLines (graphDrawObject, graphLines)
val buttonDrawObject = AppDraw.initButton ()
val triangleDrawObject = AppDraw.initTriangles ()
@@ -24,13 +30,14 @@ struct
val _ = CML.spawn (fn () =>
InputCallbacks.registerCallbacks (window, inputMailbox))
val _ = CML.spawn (fn () => EventLoop.update (inputMailbox, drawMailbox))
val _ = CML.spawn
(fn () => EventLoop.update (inputMailbox, drawMailbox, initialModel))
val _ = CML.spawn (fn () =>
EventLoop.draw
( drawMailbox
, window
, graphDrawObject
, Vector.length Constants.graphLines div 2
, Vector.length graphLines div 2
, buttonDrawObject
, 0
, triangleDrawObject