improve generated graph lines, so it aligns perfectly with clickPoints (but there are two 'todo' notes: one when the height is greather than the width, and also the constant vector when the program starts is an empty vector)
This commit is contained in:
@@ -52,15 +52,23 @@ struct
|
||||
graphDrawObject
|
||||
end
|
||||
|
||||
fun drawGraphLines (graphDrawObject: draw_object) =
|
||||
fun uploadGraphLines (graphDrawObject: draw_object, vec) =
|
||||
let
|
||||
val {vertexBuffer, ...} = graphDrawObject
|
||||
val _ = Gles3.bindBuffer vertexBuffer
|
||||
val _ = Gles3.bufferData (vec, Vector.length vec, Gles3.STATIC_DRAW ())
|
||||
in
|
||||
()
|
||||
end
|
||||
|
||||
fun drawGraphLines (graphDrawObject: draw_object, graphDrawLength) =
|
||||
let
|
||||
val {vertexBuffer, program, ...} = graphDrawObject
|
||||
val _ = Gles3.bindBuffer vertexBuffer
|
||||
val _ = Gles3.vertexAttribPointer (0, 2, 2, 0)
|
||||
val _ = Gles3.enableVertexAttribArray 0
|
||||
val _ = Gles3.useProgram program
|
||||
val _ = Gles3.drawArrays
|
||||
(Gles3.TRIANGLES (), 0, Vector.length Constants.graphLines div 2)
|
||||
val _ = Gles3.drawArrays (Gles3.TRIANGLES (), 0, graphDrawLength)
|
||||
in
|
||||
()
|
||||
end
|
||||
|
||||
@@ -41,6 +41,8 @@ struct
|
||||
\ 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 =
|
||||
AppType.genGraphLines (windowWidth, windowHeight)
|
||||
Vector.fromList []
|
||||
end
|
||||
|
||||
@@ -28,6 +28,7 @@ struct
|
||||
( drawMailbox
|
||||
, window
|
||||
, graphDrawObject
|
||||
, drawGraphLength
|
||||
, buttonDrawObject
|
||||
, buttonDrawLength
|
||||
, triangleDrawObject
|
||||
@@ -40,7 +41,7 @@ struct
|
||||
val _ = Gles3.clearColor (1.0, 1.0, 1.0, 1.0)
|
||||
val _ = Gles3.clear ()
|
||||
|
||||
val _ = AppDraw.drawGraphLines graphDrawObject
|
||||
val _ = AppDraw.drawGraphLines (graphDrawObject, drawGraphLength)
|
||||
val _ =
|
||||
AppDraw.drawTriangles (triangleDrawObject, triangleDrawLength)
|
||||
val _ = AppDraw.drawButton (buttonDrawObject, buttonDrawLength)
|
||||
@@ -52,6 +53,7 @@ struct
|
||||
( drawMailbox
|
||||
, window
|
||||
, graphDrawObject
|
||||
, drawGraphLength
|
||||
, buttonDrawObject
|
||||
, buttonDrawLength
|
||||
, triangleDrawObject
|
||||
@@ -69,6 +71,7 @@ struct
|
||||
( drawMailbox
|
||||
, window
|
||||
, graphDrawObject
|
||||
, drawGraphLength
|
||||
, buttonDrawObject
|
||||
, buttonDrawLength
|
||||
, triangleDrawObject
|
||||
@@ -87,6 +90,31 @@ struct
|
||||
( drawMailbox
|
||||
, window
|
||||
, graphDrawObject
|
||||
, drawGraphLength
|
||||
, buttonDrawObject
|
||||
, 0
|
||||
, triangleDrawObject
|
||||
, triangleDrawLength
|
||||
)
|
||||
end
|
||||
| RESIZE_TRIANGLES_BUTTONS_AND_GRAPH {triangles, graphLines} =>
|
||||
let
|
||||
val _ = print ("resize in event loop\n")
|
||||
val _ =
|
||||
AppDraw.uploadTrianglesVector
|
||||
(triangleDrawObject, triangles)
|
||||
val triangleDrawLength = Vector.length triangles div 2
|
||||
(* buttons are reset by setting buttonDrawLength to 0 *)
|
||||
val _ =
|
||||
AppDraw.uploadGraphLines
|
||||
(graphDrawObject, graphLines)
|
||||
val drawGraphLength = Vector.length graphLines div 2
|
||||
in
|
||||
draw
|
||||
( drawMailbox
|
||||
, window
|
||||
, graphDrawObject
|
||||
, drawGraphLength
|
||||
, buttonDrawObject
|
||||
, 0
|
||||
, triangleDrawObject
|
||||
@@ -98,6 +126,7 @@ struct
|
||||
( drawMailbox
|
||||
, window
|
||||
, graphDrawObject
|
||||
, drawGraphLength
|
||||
, buttonDrawObject
|
||||
, buttonDrawLength
|
||||
, triangleDrawObject
|
||||
|
||||
@@ -30,6 +30,7 @@ struct
|
||||
( drawMailbox
|
||||
, window
|
||||
, graphDrawObject
|
||||
, Vector.length Constants.graphLines div 2
|
||||
, buttonDrawObject
|
||||
, 0
|
||||
, triangleDrawObject
|
||||
|
||||
Reference in New Issue
Block a user