Page 1 of 1

[Resolved]How to quit a game properly using a button

Posted: Thu Dec 01, 2011 11:03
by metylbk
I use Ogre, IOS, CEGUI to develop my Game. this is main.cpp
CMKGame* game = CMKGame::create();
if(game->init())
game->run();
CMKGame::destroy();

After init Ogre, I create a render window:
Ogre::RenderWindow* pRenderWindow = Ogre::Root::getSingleton().createRenderWindow(
"MK", 1024, 768, false, &windowParametterList);
If I click on default Close button on the Main render window, the window will be close and the CMKGame::destroy function will be called to unload resources and destroy other things. So Game exit properly.
But, In login Game state, I have a button to exit the game, and when click on this button, I wanna exit game. So I call the function CMKGame::destroy in OnExitButtonClicked(), but the Render window is not closed so the game is crashed because of something relate to OIS mouse capture, click.
How can I close the Render Window before calling CMKGame::destroy or any one has other solutions to resolve this problem.

Re: How to quit a game properly using a button in CEGUI

Posted: Thu Dec 01, 2011 14:05
by Kulik
Not a CEGUI question at all. You probably should flip some switch that will cause the runloop to terminate.

EDIT: http://www.ogre3d.org/forums/viewtopic.php?f=2&t=67793

Re: [Resolved]How to quit a game properly using a button

Posted: Fri Dec 02, 2011 05:03
by metylbk