
Hi. 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. 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. Am i doing something wrong? Anyway, thanks for a good library. David

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.

On Tue, Sep 07, 2004 at 06:26:11PM +0200, Sven Panne wrote:
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.
When i used GLUT for visual c++ it atleast correctly exited the program when i closed the window (and that is really the only thing i want to do). HOpenGL doesn't do this. I don't know much about GLUT so maybe you are still right in that this is GLUT's fault, but I just wanted to point this out.
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? :-)
Is it? I don't get that behaviour with hugs/ghci with normal programs here (i.e the interpreter programs themselves aren't exited when i call exitWith). The reason hugs/ghci go down in this case is probably because the exitWith call makes HOpenGL destroy the last window in response to the exitException that is thrown. So the problem is really that the interpreters don't run the interpreted programs in a separate process to protect the interpreter interfaces. Which makes it a "Haskell-tools" issue? :)
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/).
I'll definitely do that. I've wanted to try wxHaskell anyway for a school project. David

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.
OpenGL doesn't deal with window management; that's handled by
whichever UI toolkit you are using. GLUT responds to window deletion
by either calling exit (X11):
case ClientMessage:
if (event.xclient.data.l[0] == __glutWMDeleteWindow)
exit(0);
break;
or PostQuitMessage() (Win32):
case WM_CLOSE:
PostQuitMessage(0);
If you want more control, you'll need to use something other than
GLUT, e.g. GTK+HS or wxHaskell.
--
Glynn Clements
participants (3)
-
David Waern
-
Glynn Clements
-
Sven Panne