haskell - 需要 renderString 解释
问题描述
我使用 GLUT 在 Haskell 中编写显示回调
这是开始:
display :: IORef Float -> IORef [(GLfloat , GLfloat ,GLfloat )] -> IORef Akkord-> DisplayCallback
display remain colors gespielt= do
clear [ ColorBuffer ]
renderPrimitive Quads $ do
--lots of things are rendered
最后,我试图显示一种分数(gespielt):
g <- get gespielt
color3f 0 0 0
preservingMatrix $ do
renderString Fixed9By15 "Hallo"
flush
“你好”将被替换为 (Show g)
但结果是一样的,没有任何文字显示在任何地方
没有编译错误,我尝试更改颜色并缩放文本
我从 haskell.org OpenGLTutorial 偷了这个:
color3f :: GLfloat -> GLfloat -> GLfloat -> IO ()
color3f r g b = color $ Color3 r g (b :: GLfloat)
我在这里做错了什么?
解决方案
我从这里使用了一种解决方法:如何在 Glut - Fungen - Haskell 中使用其他字体
putGameText [] = return ()
putGameText ((text,font ,(x,y), r,g,b):ts) = do
loadIdentity
color (Color3 r g (b :: GLfloat))
rasterPos (Vertex2 x (y :: GLfloat))
renderString font text
putGameText ts
我假设 renderString 需要首先调用 rasterPos 或类似的
推荐阅读
- html - 标签没有浮动到顶部
- c# - 点表示法替代方案
- spring-boot - Spring Security - 如何在非安全和安全页面中获取经过身份验证的对象?
- python - 在 Python 中使用字典查找字谜
- python - flask/python 创建多个 TestCase 类返回 404
- python - 在 Python 中创建多级字典词性标注器
- c++ - C++ gcc`floorf`不是`std`的成员?
- django - 安装 SSL 后 Ubuntu 18.04 上的 Django 站点与 Apache2 无法正常工作
- ios - URLSession.dataTask(with:completionHandler:) 是否总是只调用一次completionHandler?
- c# - 从右向左移动时Unity 2D敌人移动脚本不翻转