draw super basic text to screen
This commit is contained in:
@@ -55,12 +55,18 @@ struct
|
||||
}
|
||||
end
|
||||
|
||||
fun uploadText ({textVertexBuffer, ...}: t, vec) =
|
||||
fun uploadText
|
||||
({textVertexBuffer, textProgram, window, textDrawLength = _}: t, vec) =
|
||||
let
|
||||
val _ = Gles3.bindBuffer textVertexBuffer
|
||||
val _ = Gles3.bufferData (vec, Vector.length vec, Gles3.STATIC_DRAW)
|
||||
val newTextDrawLength = Vector.length vec div 5
|
||||
in
|
||||
()
|
||||
{ textVertexBuffer = textVertexBuffer
|
||||
, textProgram = textProgram
|
||||
, window = window
|
||||
, textDrawLength = newTextDrawLength
|
||||
}
|
||||
end
|
||||
|
||||
fun drawText ({textVertexBuffer, textProgram, textDrawLength, ...}: t) =
|
||||
@@ -91,7 +97,7 @@ struct
|
||||
case Glfw.windowShouldClose window of
|
||||
false =>
|
||||
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 _ = draw shellState
|
||||
|
||||
@@ -2,6 +2,11 @@ structure Shell =
|
||||
struct
|
||||
open CML
|
||||
|
||||
fun ioToString (io, acc) =
|
||||
case TextIO.inputLine io of
|
||||
SOME str => ioToString (io, acc ^ str)
|
||||
| NONE => acc
|
||||
|
||||
fun main () =
|
||||
let
|
||||
(* Set up GLFW. *)
|
||||
@@ -9,11 +14,21 @@ struct
|
||||
val _ = Glfw.windowHint (Glfw.CONTEXT_VERSION_MAJOR (), 3)
|
||||
val _ = Glfw.windowHint (Glfw.DEPRECATED (), Glfw.FALSE ())
|
||||
val _ = Glfw.windowHint (Glfw.SAMPLES (), 4)
|
||||
val window = Glfw.createWindow (1600, 900, "shf")
|
||||
val window = Glfw.createWindow (1920, 1080, "shf")
|
||||
val _ = Glfw.makeContextCurrent window
|
||||
val _ = Gles3.loadGlad ()
|
||||
|
||||
val _ = GlDraw.loop window
|
||||
(* upload text vector *)
|
||||
val io = TextIO.openIn "fcore/buffer.sml"
|
||||
val str = ioToString (io, "")
|
||||
val lineGap = LineGap.fromString str
|
||||
val _ = TextIO.closeIn io
|
||||
|
||||
val textVec = Buffer.startBuildTextLineGap (0, lineGap, 1920, 1080)
|
||||
val shellState = GlDraw.create window
|
||||
val shellState = GlDraw.uploadText (shellState, textVec)
|
||||
|
||||
val _ = GlDraw.helpLoop shellState
|
||||
in
|
||||
()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user