
I'm trying to get cross platform GLUT/OpenGL program to run, but even the simplest code hang on OS X with GHC 6.6 or GHC 6.6.1 import Graphics.UI.GLUT import Graphics.Rendering.OpenGL main = do getArgsAndInitialize createAWindow "Hello window" mainLoop createAWindow windowName = do createWindow windowName displayCallback $= clear [ColorBuffer] Has anyone been successful at getting GLUT to work on OS X? Regards, Paul L

This works fine for me on PPC and x86 10.4.10. Which GLUT implementation are you using? Does the code hang or does it crash? Alan Mock On Aug 1, 2007, at 7:55 PM, Paul L wrote:
I'm trying to get cross platform GLUT/OpenGL program to run, but even the simplest code hang on OS X with GHC 6.6 or GHC 6.6.1
import Graphics.UI.GLUT import Graphics.Rendering.OpenGL
main = do getArgsAndInitialize createAWindow "Hello window" mainLoop
createAWindow windowName = do createWindow windowName displayCallback $= clear [ColorBuffer]
Has anyone been successful at getting GLUT to work on OS X?
Regards, Paul L _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

I use x86 10.4.9, and loading it in GHCi doesn't work at all. It hang
after the window pops up.
BTW, compiling it using GHC to binary form seems to work. But
unfortunately this is not acceptable as loading in GHCi is crucial
for the purpose.
I'm doing a port of the SOE Graphics from HGL to OpenGL/GLUT
so that it could perform not only better but be truely cross-platform.
Being able to load and run small code snippets from command line
is likely a must-have for SOE users. The port is already working well
on both Windows and Linux, and I'm hoping the same for OS X.
Should I try another GLUT library instead? Or is it a problem of
loading dynamic libraries on OS X?
Regards,
Paul L
On 8/1/07, Alan Mock
This works fine for me on PPC and x86 10.4.10. Which GLUT implementation are you using? Does the code hang or does it crash?
Alan Mock
On Aug 1, 2007, at 7:55 PM, Paul L wrote:
I'm trying to get cross platform GLUT/OpenGL program to run, but even the simplest code hang on OS X with GHC 6.6 or GHC 6.6.1
import Graphics.UI.GLUT import Graphics.Rendering.OpenGL
main = do getArgsAndInitialize createAWindow "Hello window" mainLoop
createAWindow windowName = do createWindow windowName displayCallback $= clear [ColorBuffer]
Has anyone been successful at getting GLUT to work on OS X?
Regards, Paul L _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

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

On Aug 2, 2007, at 0:48 , Paul L wrote:
Ok, a bit hacking reveals that GLUT on Mac OS X performs differently in GHCi and when compiled.
Hm, isn't there a problem with shared library initialization in GHCi? (In a compiled program it's handled by ld.so or equivalent; ghci loads shared objects dynamically.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Ok, after spending some time looking for a solution, here is a stroke of genius by wxHaskell folks at http://wxhaskell.sourceforge.net/building-macosx.html I've tried this enableGUI trick using GHCi, it works with my GLFW interface to Haskell which suffered from the same problem as GLUT on OS X, but then it still won't work with GLUT. So, does anyone have a clue of what's going on with GLUT on OS X? Regards, Paul Liu
participants (3)
-
Alan Mock
-
Brandon S. Allbery KF8NH
-
Paul L