Registering the cleanup function with "atexit" is a good idea, but it doesn't address one of my concerns.  I have an application with fifty different windows and I don't want the application to exit when the user clicks the "x" on most of them.  So I need freeglut to support a "continue execution but close this window" option here.  If the idle callback renders to the window which has just been closed, there is bad news.

There is also a second question about the "atexit" function.  If we do go this way, do we expect the application programmer to write the cleanup function or is it part of freeglut?  And if we decide to make it part of freeglut, can the user write his own "atexit" function?  (I am simply ignorant here:  does "atexit" support multiple callbacks or is it restricted to one?)

John F. Fay

-----Original Message-----
From: Chris Purnell []
Sent: Tuesday, October 29, 2002 11:57 AM
Subject: Re: [Freeglut-developer] RE: Window Destruction Callback

On Tue, Oct 29, 2002 at 10:08:00AM -0600, Fay John F Contr AAC/WMG wrote:

> Since GLUT exits immediately, there are no more callbacks generated when the
> user clicks on the "x".  If we drop out of the freeglut main loop and then
> exit, then the idle callback may easily get called again.  (I know this
> because I was checking this out with a three-window application and it keeps
> crashing.)  Without the application defining a window destroy callback,
> there is no way for the application to find out that the window has been
> closed.  So when it tries to render the window in its idle callback, we get
> a "window ID %d not found!" warning from freeglut, followed by a program
> crash when I call "glutSwapBuffers".
> So now it's time for a design decision.  Shall we:
> (1) make the default behaviour absolutely compatible with GLUT and exit
> immediately, or
> (2) make the default behaviour clean up after itself and possible break some
> GLUT applications?

Rendering to the window in the idle callback is bad practive but people do
it.  Which is why glut exits immediatly on a window close button event.
The only other behaviour that does not break stuff is to leave the window

I still say the cleanup function should be registered with atexit().

Christopher John Purnell  | I thought I'd found a reason to live   | Just like before when I was a child
--------------------------| Only to find that dreams made of sand
What gods do you pray to? | Would just fall apart and slip through my hands

This email is sponsored by:ThinkGeek
Welcome to geek heaven.
Freeglut-developer mailing list