Implement text rendering using geometry shader

This commit is contained in:
2021-02-15 14:03:15 +01:00
parent 9747b5b876
commit 9f4497fb39
4 changed files with 27 additions and 12 deletions
+22 -11
View File
@@ -113,7 +113,7 @@ scale3 a b (x,y,z) = (x*a,y*b,z)
scale :: Float -> Float -> Picture -> Picture
{-# INLINE scale #-}
--scale x y = over scPosTri (mapVC $ scale3 x y) . over scPosChar (mapVC $ scale3 x y)
scale x y = overPos $ scale3 x y
scale x y pic = overPos (scale3 x y) $ over scTexChar (fmap (second (*x))) pic
rotate3 :: Float -> Point3 -> Point3
{-# INLINE rotate3 #-}
@@ -170,20 +170,31 @@ charToScene :: Char -> Picture
charToScene c = Scene
{_scPosTri = mempty
,_scColTri = mempty
,_scPosChar = toVC [(0.0 ,0.0 ,0)
,(dimText,0.0 ,0)
,(dimText,dimText*2,0)
,(0.0 ,0.0 ,0)
,(dimText,dimText*2,0)
,(0.0 ,dimText*2,0)
]
,_scColChar = toVC $ take 6 $ repeat white
,_scTexChar = toVC $ [(s,1) ,(e,1) ,(e,0) ,(s,1) ,(e,0) ,(s,0)]
,_scPosChar = toVC [(0.0,0.0,0)]
,_scColChar = toVC [white]
,_scTexChar = toVC [(offset,100)]
}
where x = 1/128
s = offset * x
e = s + x
offset = fromIntegral (fromEnum c) - 32
--charToScene :: Char -> Picture
--charToScene c = Scene
-- {_scPosTri = mempty
-- ,_scColTri = mempty
-- ,_scPosChar = toVC [(0.0 ,0.0 ,0)
-- ,(dimText,0.0 ,0)
-- ,(dimText,dimText*2,0)
-- ,(0.0 ,0.0 ,0)
-- ,(dimText,dimText*2,0)
-- ,(0.0 ,dimText*2,0)
-- ]
-- ,_scColChar = toVC $ take 6 $ repeat white
-- ,_scTexChar = toVC $ [(s,1) ,(e,1) ,(e,0) ,(s,1) ,(e,0) ,(s,0)]
-- }
-- where x = 1/128
-- s = offset * x
-- e = s + x
-- offset = fromIntegral (fromEnum c) - 32
dimText = 100