PDA

View Full Version : Closing OpenGL window in multithreaded application



Conor
10-30-2006, 04:34 PM
Hello,

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);

glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);

glutInitWindowPosition(130,100);
glutInitWindowSize(50,50);
int mainWindowID = glutCreateWindow("Configuration tool");
glutDisplayFunc(renderConfigurationTool);Thanks,
Conor.

mikael_aronsson
11-06-2006, 10:55 PM
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.

V-man
11-07-2006, 05:29 AM
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.