adjust imperative shell to use xyz coordinates for position, instead of simply xy; need to ensure the functional core code outputs a vector in this format too

This commit is contained in:
2025-09-11 01:43:23 +01:00
parent 781691060c
commit 2e0f749229
4 changed files with 10 additions and 17 deletions

View File

@@ -40,12 +40,10 @@ struct
val textAcc = Vector.concat textAcc
val bgAcc = Vector.concat bgAcc
val textMsg = REDRAW_TEXT textAcc
val cursorMsg = REDRAW_CURSOR cursorAcc
val bgMsg = REDRAW_BG bgAcc
val vec = Vector.concat [textAcc, bgAcc, cursorAcc]
val drawMsg = DRAW_TEXT vec
in
DRAW bgMsg :: DRAW textMsg :: DRAW cursorMsg :: msgs
DRAW drawMsg :: msgs
end
(* builds text from a string with char-wrap.

View File

@@ -1,8 +1,2 @@
structure DrawMsg =
struct
datatype t =
REDRAW_TEXT of Real32.real vector
| REDRAW_CURSOR of Real32.real vector
| REDRAW_BG of Real32.real vector
| YANK of string
end
struct datatype t = DRAW_TEXT of Real32.real vector | YANK of string end

View File

@@ -1,7 +1,8 @@
structure GlDraw =
struct
open CML
open DrawMsg K
open DrawMsg
(* The name doesn't make it clear, but this structure
* couples GLFW and OpenGL.
* I'm not sure if I will use native windowing systems
@@ -76,7 +77,7 @@ struct
shellState
val _ = Gles3.bufferData (vec, Vector.length vec, Gles3.STATIC_DRAW)
val newTextDrawLength = Vector.length vec div 5
val newTextDrawLength = Vector.length vec div 6
in
{ textVertexBuffer = textVertexBuffer
, textProgram = textProgram
@@ -90,7 +91,7 @@ struct
val {textVertexBuffer, textDrawLength, textProgram, window = _} =
drawObject
in
Gles3.drawArrays (Gles3.TRIANGLES, 0, drawLength)
Gles3.drawArrays (Gles3.TRIANGLES, 0, textDrawLength)
end
fun yank (shellState: t, str) =
@@ -109,7 +110,7 @@ struct
shellState
in
case msg of
DRAW vec => uploadText (shellState, textVec)
DRAW_TEXT textVec => uploadText (shellState, textVec)
| YANK str => yank (shellState, str)
end

View File

@@ -1,6 +1,6 @@
structure GlShaders =
struct
val xyrgbVertexShaderString =
val xyzRgbVertexShaderString =
"#version 300 es\n\
\layout (location = 0) in vec3 apos;\n\
\layout (location = 1) in vec3 col;\n\