Closing OpenGL window in multithreaded application


I am writing a multithreaded application, where a selection from a menu in one openGL window opens a new configuration window (which should only be open temporaraly). I spawn another thread to create and render this new window.

I want the user to be able to close this window and return to work on the original window but at the moment, when the new configuration window is closed, it closes all other windows (eg the entire application closes). I don’t understand this as it is a seperate thread.

Both windows have seperate Display Functions.

Is there any command to close a GL window that wont cause the entire app to close? ( exit(0); causes this)

The windows are created with the following code (if that matters)…

glutInit( &(__argc), __argv);

int mainWindowID = glutCreateWindow("Configuration tool");


Well, as you use glut this might be the problem, glut was never designed to work in a multithreaded environment, have you tried to create the second window in the same thread as the main window ? does that give the same problem ?

If not then I guess you should not use multithreading with glut.

You should use some other windowing lib like SDL.
GLUT is for making demoes and is not even well programmed so many GLUT demoes just abort by using the exit function. Later on, glut EXIT HACK was added so that programs could properly shutdown.

Seriously, drop GLUT if you are not making a demo.