renderString explanation needed

Viewed 47

Im writing a display Callback in Haskell using GLUT

here is the beginning:

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 

at the very end I'm trying to display a sort of score (gespielt):

  g <- get gespielt
  color3f 0 0 0
  preservingMatrix $ do
    renderString Fixed9By15  "Hallo"
    

  flush

"Hallo" is going to get replaced with (Show g)

but the result is the same no text is displayed anywhere

there are no compilation errors and I've tried to change the color and scaling the text

I stole this from the haskell.org OpenGLTutorial:

color3f :: GLfloat -> GLfloat -> GLfloat -> IO ()
color3f r g b = color $ Color3 r g (b :: GLfloat)

what am I doing wrong here?

1 Answers

I used a workaround from here: 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

I assume that renderString requires rasterPos or similar to be envoked first

Related