
David Waern wrote:
How are you supposed to handle the event of a user who closes the hopengl window? I see no way to detect this with the API. The main loop of hopengl just keeps running.
To be exact, it's the GLUT part of HOpenGL which misses the functionality you want. But this is a direct consequence of the GLUT library, and there is not much HOpenGL can do about it. The freeglut library (http://freeglut.sourceforge.net/) has some extensions in this direction, but it's not yet very widespread and there is no support for those extensions in HOpenGL currently (but this might change some day).
Also, when I have the hopengl mainloop running and I destroy the current window (or exit with System.Exit.exitWith), both ghci and hugs just dies along with the app.
When you destroy the last window, GLUT exits the application internally, so it's not a Haskell issue. Using exitWith exits ghci/hugs, that's what it is supposed to do, isn't it? :-)
Am i doing something wrong?
No, not at all. GLUT is only meant as a simple UI library, if you want something more polished, you can try gtk+hs (http://www.cse.unsw.edu.au/~chak/haskell/gtk/) or wxHaskell (http://wxhaskell.sourceforge.net/). Both have OpenGL support, so you can continue using the OpenGL package of HOpenGL for rendering, and both have more sensible ways of handling your windowing issues. Cheers, S.