MaiaVictor
MaiaVictor

Reputation: 52957

Hello World for OpenGL+GLUT in Haskell not working on OSX Lion

The following program:

import Graphics.Rendering.OpenGL
import Graphics.UI.GLUT
main = do 
  (progname, _) <- getArgsAndInitialize
  createWindow "Hello World"
  mainLoop

compiled with the command:

ghc -package GLUT HelloWorld.hs -o HelloWorld

as explained on this tutorial fails to execute on OSX Lion, displaying the following error message:

2013-09-07 20:31:20.372 aff[8561:60b] GLUT Warning: The following is a new check for GLUT 3.0; update your code.
2013-09-07 20:31:20.373 aff[8561:60b] GLUT Fatal Error: redisplay needed for window 1, but no display callback.

Upvotes: 2

Views: 545

Answers (1)

Laar
Laar

Reputation: 614

First of all, I'm not on OS X and could not reproduce the error (nor the warning for that matter). Furthermore I'm probably using different version of all the libraries. Note that these kind of differences between operating systems are (unfortunately) not that uncommon. When running the program I got a copy of the pixels underneath it, like the tutorial writer seems to expect.

The error message states

redisplay needed for window 1, but no display callback

Thus my guess is that you need to register the displayCallback. So, in line with the next part of the tutorial, I added

displayCallback $= clear [ ColorBuffer ]

before the mainloop. Yet it did not fix the pixel carrying behaviour. To fix that I changed it to

displayCallback $= (clear [ColorBuffer] >> swapBuffers)

Which also updates the buffer on screen.

P.S. Note that the tutorial is from 2006, it might have bit rotted a bit. Furthermore OpenGL 2.1 was at that time the latest version of OpenGL.

Upvotes: 3

Related Questions