Use texture array for character rendering, condense rendering

This commit is contained in:
2023-03-23 14:08:07 +00:00
parent 68b43f29ff
commit 3350a8dc30
9 changed files with 80 additions and 42 deletions
+12 -11
View File
@@ -202,7 +202,7 @@ text :: String -> Picture
{-# INLINE text #-}
text = map f . stringToList
where
f (pos, col, V2 a b) = Verx pos col [a, b] BottomLayer textNum
f (pos, col, V3 a b c) = Verx pos col [a, b, c, 1] BottomLayer textNum
line :: [Point2] -> Picture
{-# INLINE line #-}
@@ -291,25 +291,26 @@ overCol :: (Point4 -> Point4) -> Verx -> Verx
overCol f vx = vx{_vxCol = f (_vxCol vx)}
-- no premature optimisation, consider changing to use texture arrays
stringToList :: String -> [(Point3, Point4, Point2)]
stringToList :: String -> [(Point3, Point4, Point3)]
{-# INLINE stringToList #-}
stringToList = concatMap (uncurry charToTuple) . zip [0, 0.9 * dimText ..]
where
dimText = 100
charToTuple :: Float -> Char -> [(Point3, Point4, Point2)]
charToTuple :: Float -> Char -> [(Point3, Point4, Point3)]
{-# INLINE charToTuple #-}
charToTuple x c =
[ (V3 (x -50) (-100) 0, white, V2 offset 1)
, (V3 (x -50) 100 0, white, V2 offset 0)
, (V3 (x + 50) 100 0, white, V2 (offset + 1) 0)
, (V3 (x -50) (-100) 0, white, V2 offset 1)
, (V3 (x + 50) (-100) 0, white, V2 (offset + 1) 1)
, (V3 (x + 50) 100 0, white, V2 (offset + 1) 0)
]
charToTuple xoff c = [f 0 0, f 1 0, f 1 1, f 0 0, f 1 1, f 0 1]
where
f x y = (V3 (xoff - 50 + x * 100) (100 - y * 200) 0, white, V3 x y offset)
offset = fromIntegral (fromEnum c) - 32
--charToTuple' :: Float -> Char -> [(Point3, Point4, Point3)]
--{-# INLINE charToTuple' #-}
--charToTuple' xoff c = [f 0 0, f 1 0, f 1 1, f 0 0, f 1 1, f 0 1]
-- where
-- f x y = (V3 (xoff + x * 100) (y * 200) 0, white, V3 x y offset)
-- offset = fromIntegral (fromEnum c) - 32
mirrorxz :: Picture -> Picture
mirrorxz = picMap (overPos flipy)
where
-1
View File
@@ -36,7 +36,6 @@ numLayers = length [minBound :: Layer .. maxBound]
data ShadNum
= PolyShad
| BezShad
| TextShad
| ArcShad
| EllShad