[Haskell-cafe] GHC, GLUT and OS X

Paul L ninegua at gmail.com
Thu Aug 2 00:48:04 EDT 2007


Ok, a bit hacking reveals that GLUT on Mac OS X performs differently
in GHCi and when compiled.

I use the following code:

====

import Graphics.UI.GLUT
import Graphics.Rendering.OpenGL

main = do
  getArgsAndInitialize
  createAWindow "Hello window"
  mainLoop

createAWindow windowName = do
  createWindow windowName
  displayCallback $= (clear [ColorBuffer] >> swapBuffers)
  --idleCallback $= Just (postRedisplay Nothing)
  passiveMotionCallback $= Just (putStrLn . show)

====

When compiled, it renders a black screen and prints the event when you
move mouse over. It's crucial to have swapBuffers in displayCallback,
otherwise it will not render.

But if run in GHCi, it won't render a thing unless idleCallback line
is uncommented. Also, it won't produce any output at mouse over.
Another strange thing is with idleCallback set and swapBuffers
removed, it still renders black screen in GHCi, but will not render
when compiled.

I wonder why the event callback is blocked when using GLUT in GHCi?

Regards,
Paul L


More information about the Haskell-Cafe mailing list