Glut program exit

I would like to run some deinitialization code before the program exits, but after the user ‘closes’ the glut window.

Is there a way to catch when the user closes the main glut window?

Thanks!

Not sure about a cross platform way, I haven’t used GLUT in years now. But on a windows platform you can use atexit() or _onexit(), you can look them up in your MSDEV help. atexit() seems to be ANSI C from the documentation, so that should work on any ANSI C compiler.

int atexit( void ( __cdecl *func )( void ) );

Routine
atexit
Required Header
<stdlib.h>
Compatibility
ANSI, Win 95, Win NT

[This message has been edited by Jeffry J Brickley (edited 06-25-2002).]

Originally posted by maxsteel:
[b]I would like to run some deinitialization code before the program exits, but after the user ‘closes’ the glut window.

Is there a way to catch when the user closes the main glut window?

Thanks![/b]

There are patches - see [The OpenGL Toolkit FAQ](http://www.mathies.com/glfaq/\)

Regards,
Jim

thanks. that is just what i was looking for.

seems silly that glut does not have the close window callback at least.

Its really annoying when you create multiple windows to display various views & when the user closes one of these windows, the program exits.

Yes, annoying, which is why I wrote the
window manager close callbacks!

You will have to build your own glut though,
from source and include the new code.

I have emailed Nate and Mark K to see if we can get a revised GLUT out to everyone, but
have not had any reply from either …

Let me know if you find the code useful …

Rob.

oh yes, info at

http://www-users.york.ac.uk/~rpf1/glut/html

Any word from Nate?

It’s a real problem that GLUT, used by many people, is both unsupported and under a license that doesn’t permit modification by others.
Should we switch to FreeGLUT?

What is the state of FreeGlut anyway, there hasn’t been a new release since January?

Originally posted by cthulhu666:
What is the state of FreeGlut anyway, there hasn’t been a new release since January?

They think they’re done. Nothing more to do.
And they’re not answering.

Rob Fletcher put in a request to put his window-close-callback code in FreeGlut, and nobody answered.

>>What is the state of FreeGlut anyway, there hasn’t been a new release
>>since January?
>
>They think they’re done. Nothing more to do.
>And they’re not answering.
>
>Rob Fletcher put in a request to put his window-close-callback code in
>FreeGlut, and nobody answered

Look here:

http://sourceforge.net/mail/?group_id=1032

The freeglut developer mailing list is monitored, and there has been
some development activity since the last release. However I’m not
sure anyone looks at the SourceForge Feature Request Tracking System
where that request was posted.

I investigated using freeglut for my project a few months ago but ran
into quite a few missing features. Now my code does things that you
wouldn’t normally do in a game project (like single buffered mode) so
maybe it works fine for other folks. I get the impression that it
works ok for whatever the developers use it for, so they’re probably
not all that motivated to change it. Perhaps someone with time and
motivation should join the developer team and crank things up. They
let me in, so my patches will eventually make it into the CVS
archives.

Originally posted by ldglite:
[b]

Look here:

http://sourceforge.net/mail/?group_id=1032

The freeglut developer mailing list is monitored, and there has been
some development activity since the last release. However I’m not
sure anyone looks at the SourceForge Feature Request Tracking System
where that request was posted.

[/b]

You can’t post to any of the FreeGLUT forums unless you’re a FreeGLUT developer. Somebody was spamming the FreeGLUT developer list (in an Asian font, even), so they seem to have locked down their lists.

Is there some way to jumpstart this fix? Any ideas?

So much OpenGL usage involves GLUT; it can’t just be abandoned without impacting OpenGL itself.