View Full Version : Close Program when click X on GLUT Window
11-16-2007, 10:58 PM
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.
11-17-2007, 06:26 AM
Personnaly I really like GLFW : simple, much more game-oriented than GLUT, multiplateform too.
11-17-2007, 02:15 PM
Does GLFW support input (including gamepads) and networking?
11-17-2007, 05:15 PM
yes for input
no for networking
check "Features" here :
11-17-2007, 05:22 PM
Game network is quite specific so you will need to use another library along GLFW (or do it yourself with sockets).
Some searching for "network game library" gave the following links :
11-17-2007, 09:46 PM
Thank you for the help ZbuffeR.
11-18-2007, 12:49 AM
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).
11-19-2007, 07:59 AM
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.
X/Win snippet attached. I don't know what GLUT you're using (glX/wgl/etc.), but OpenGLUT (http://openglut.sourceforge.net/) 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 );
processXEvents( wm_protocols, wm_delete_window );
void processXEvents( Atom wm_protocols, Atom wm_delete_window )
while ( XEventsQueued( Win.display, QueuedAfterFlush ) )
XNextEvent( Win.display, &event );
switch ( event.type )
if ( event.xclient.message_type == wm_protocols &&
Atom( event.xclient.data.l ) == wm_delete_window )
//guDebug( "Received WM_DELETE_WINDOW" );
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.