PDA

View Full Version : Closing a GLUT App



Jan
08-22-2004, 10:45 AM
Hi there

Simple thing: I want to exit my GLUT app, how to do that?

I donīt want to use the "exit ()" function, because it stops my whole app, but i only want to stop GLUTs Mainloop.

Is there a clean way to do that? I couldnīt find anything in GLUTs doc. Simply destroying the window when ESC was pressed, yields to a crash.

Thanks,
Jan.

Bob
08-23-2004, 02:34 AM
You can't exit the main loop in GLUT. If this is not what you want, then you have to use another windowing library. I think GLFW is pretty good.

Sumpfratte
08-23-2004, 06:24 AM
Hello,

I think there is no other possibility than to call exit because the documentation says that glutMainLoop() never returns.
I suppose that it has a while(1) loop which can't be left.

Sumpfratte

Jan
08-23-2004, 10:57 AM
Hm, thatīs a bit strange, isnīt it? Did they simply forget to include that into GLUT?

Problem is, i cannot change to anything else, i have to use GLUT.

Well, under Windows, i am pretty sure i can exit the main-loop, by sending a WM_CLOSE message. Any idea, how to do that under Linux?

Jan.

Bob
08-23-2004, 03:49 PM
If you take a look at the GLUT source, you can see that there is no way out of the loop entered in glutMainLoop. If you manage to send something that close the window, you're not going to get out of glutMainLoop.

I doubt this is a mistake, since GLUT have been around for quite some time, even before the development of it stopped a few years ago, and is used quite alot. I would guess that there was no real reason for it, since you're not supposed to use GLUT for anything but smaller demos and similar stuff anyways.

What is it exactly you want to do after exiting the main loop? Are you really sure it's something that can't be done right before calling exit() to exit the program or something?

Jan
08-24-2004, 01:48 PM
Well, i wouldnīt use GLUT if i wasnīt forced to use it. Thatīs why i do use it.

Actually, i wanted to do some clean up after the main-loop. But well, if itīs not possible to exit the main-loop, i will have to do the clean up somewhere else.

I still think it is a poor decision, not to include something to properly exit that loop. exit() looks pretty much like a brute-force thing, i thought there might be a more elegant way.

Thanks anyway,
Jan.

08-24-2004, 02:44 PM
what's wrong with atexit() ?

:)