I’ve looked around the web and couldn’t seem to find a correct solution, and figured someone probably knew how to do this already. Basically the problem is that in debug mode in Visual Studios 2005, I have the console and GLUT window pop up, so if I want to quit I just click the ‘x’ on the console to close it, but in release mode I have it so the console window does not appear, but the problem with this is when I click on ‘x’ on the GLUT Window and close it, the application is still running. I want to be able to click the ‘x’ on the GLUT Window to close my application, but I have really no idea how to because just began using openGl and GLUT.
Also, I am making a 3D video game, and have heard that GLUT may not be the best for doing so, and was wondering instead of worrying about GLUT should I move onto some other library.
Plib is good and simple, but you’ll need to do a lot of stuff on top. If you are doing a real-time 3D game then (depending on the game type) the networking is probably the hardest part (it might work, but the game play sucks).
Haven’t tried this http://www.zoidcom.com but it looks like it considers all the problems (still at a release level < 1.0 though).
X/Win snippet attached. I don’t know what GLUT you’re using (glX/wgl/etc.), but OpenGLUT appears to take care of this for you, for the X/glX path. Perhaps you just need a GLUT upgrade.
If you want a small working test prog that illustrates this for the X/glX path, let me know. Term to google for is WM_DELETE_WINDOW.
// Register to receive window close events (the "X" window manager button)
Atom wm_protocols = XInternAtom( Win.display, "WM_PROTOCOLS" , False);
Atom wm_delete_window = XInternAtom( Win.display, "WM_DELETE_WINDOW", False);
XSetWMProtocols( Win.display, Win.win, &wm_delete_window, True );
...
while (1)
{
...
processXEvents( wm_protocols, wm_delete_window );
}
...
void processXEvents( Atom wm_protocols, Atom wm_delete_window )
{
while ( XEventsQueued( Win.display, QueuedAfterFlush ) )
{
XEvent event;
XNextEvent( Win.display, &event );
...
switch ( event.type )
{
...
case ClientMessage:
{
if ( event.xclient.message_type == wm_protocols &&
Atom( event.xclient.data.l[0] ) == wm_delete_window )
{
//guDebug( "Received WM_DELETE_WINDOW" );
exit(0);
}
break;
}
}
}
...