add block.sml which just generates a block for OpenGL

This commit is contained in:
2024-12-10 11:55:40 +00:00
parent a1b8aead30
commit fb2be7be73
3 changed files with 41 additions and 0 deletions

2
Makefile Normal file
View File

@@ -0,0 +1,2 @@
run:
mlton oms.mlb && ./oms

27
fcore/block.sml Normal file
View File

@@ -0,0 +1,27 @@
structure Block =
struct
fun lerp (startX, startY, drawWidth, drawHeight, windowWidth, windowHeight, r, g, b) : Real32.real vector =
let
val startX = Real32.fromInt startX
val startY = Real32.fromInt startY
val endY = windowHeight - startY
val startY = windowHeight - (startY + drawHeight)
val endX = startX + drawWidth
val windowHeight = windowHeight / 2.0
val windowWidth = windowWidth / 2.0
in
#[ (((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 0.0)) + (endX * 0.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 1.0)) + (endY * 1.0)) / windowHeight) - 1.0, r, g, b,
(((startX * (1.0 - 1.0)) + (endX * 1.0)) / windowWidth) - 1.0,
(((startY * (1.0 - 0.0)) + (endY * 0.0)) / windowHeight) - 1.0, r, g, b
]
end
end

12
oms.mlb Normal file
View File

@@ -0,0 +1,12 @@
$(SML_LIB)/basis/basis.mlb
(* fcore *)
ann
"allowVectorExps true"
in
fcore/block.sml
end
fcore/quad-tree.sml
fcore/player.sml
fcore/wall.sml