【问题标题】:renderString explanation needed需要 renderString 解释
【发布时间】:2021-08-09 22:20:29
【问题描述】:

我正在使用 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)

我在这里做错了什么?

【问题讨论】:

    标签: haskell opengl glut


    【解决方案1】:

    我从这里使用了一种解决方法:How can I use other fonts in 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 或类似的方法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-23
      • 2022-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多