exit gracefully and call destructor of the current active example
fflush after printf implemented stepForward and Shutdown for the SharedMemory client/server
This commit is contained in:
@@ -42,13 +42,17 @@ class MyMenuItems : public Gwen::Controls::Base
|
||||
public:
|
||||
|
||||
b3FileOpenCallback m_fileOpenCallback;
|
||||
b3QuitCallback m_quitCallback;
|
||||
|
||||
MyMenuItems() :Gwen::Controls::Base(0),m_fileOpenCallback(0)
|
||||
{
|
||||
}
|
||||
void myQuitApp( Gwen::Controls::Base* pControl )
|
||||
{
|
||||
exit(0);
|
||||
if (m_quitCallback)
|
||||
{
|
||||
(*m_quitCallback)();
|
||||
}
|
||||
}
|
||||
void fileOpen( Gwen::Controls::Base* pControl )
|
||||
{
|
||||
@@ -74,7 +78,8 @@ struct MyTestMenuBar : public Gwen::Controls::MenuStrip
|
||||
{
|
||||
m_menuItems = new MyMenuItems();
|
||||
m_menuItems->m_fileOpenCallback = 0;
|
||||
|
||||
m_menuItems->m_quitCallback = 0;
|
||||
|
||||
m_fileMenu = AddItem( L"File" );
|
||||
|
||||
m_fileMenu->GetMenu()->AddItem(L"Open",m_menuItems,(Gwen::Event::Handler::Function)&MyMenuItems::fileOpen);
|
||||
@@ -230,6 +235,11 @@ void GwenUserInterface::registerFileOpenCallback(b3FileOpenCallback callback)
|
||||
m_data->m_menuItems->m_fileOpenCallback = callback;
|
||||
}
|
||||
|
||||
void GwenUserInterface::registerQuitCallback(b3QuitCallback callback)
|
||||
{
|
||||
m_data->m_menuItems->m_quitCallback = callback;
|
||||
}
|
||||
|
||||
void GwenUserInterface::init(int width, int height,Gwen::Renderer::Base* renderer,float retinaScale)
|
||||
{
|
||||
m_data->m_curYposition = 20;
|
||||
|
||||
@@ -6,6 +6,7 @@ struct GwenInternalData;
|
||||
typedef void (*b3ComboBoxCallback) (int combobox, const char* item);
|
||||
typedef void (*b3ToggleButtonCallback)(int button, int state);
|
||||
typedef void (*b3FileOpenCallback)();
|
||||
typedef void (*b3QuitCallback)();
|
||||
|
||||
namespace Gwen
|
||||
{
|
||||
@@ -53,6 +54,7 @@ class GwenUserInterface
|
||||
|
||||
|
||||
void registerFileOpenCallback(b3FileOpenCallback callback);
|
||||
void registerQuitCallback(b3QuitCallback callback);
|
||||
|
||||
GwenInternalData* getInternalData()
|
||||
{
|
||||
|
||||
@@ -88,7 +88,18 @@ int gGpuArraySizeZ=15;
|
||||
|
||||
|
||||
|
||||
|
||||
void deleteDemo()
|
||||
{
|
||||
if (sCurrentDemo)
|
||||
{
|
||||
sCurrentDemo->exitPhysics();
|
||||
s_instancingRenderer->removeAllInstances();
|
||||
delete sCurrentDemo;
|
||||
sCurrentDemo=0;
|
||||
delete s_guiHelper;
|
||||
s_guiHelper = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
b3KeyboardCallback prevKeyboardCallback = 0;
|
||||
@@ -163,6 +174,7 @@ void MyKeyboardCallback(int key, int state)
|
||||
#endif
|
||||
if (key==B3G_ESCAPE && s_window)
|
||||
{
|
||||
|
||||
s_window->setRequestExit();
|
||||
}
|
||||
|
||||
@@ -270,15 +282,8 @@ void selectDemo(int demoIndex)
|
||||
{
|
||||
demoIndex = 0;
|
||||
}
|
||||
if (sCurrentDemo)
|
||||
{
|
||||
sCurrentDemo->exitPhysics();
|
||||
s_instancingRenderer->removeAllInstances();
|
||||
delete sCurrentDemo;
|
||||
sCurrentDemo=0;
|
||||
delete s_guiHelper;
|
||||
s_guiHelper = 0;
|
||||
}
|
||||
deleteDemo();
|
||||
|
||||
CommonExampleInterface::CreateFunc* func = gAllExamples->getExampleCreateFunc(demoIndex);
|
||||
if (func)
|
||||
{
|
||||
@@ -495,6 +500,12 @@ struct GL3TexLoader : public MyTextureLoader
|
||||
}
|
||||
};
|
||||
|
||||
void quitCallback()
|
||||
{
|
||||
|
||||
s_window->setRequestExit();
|
||||
}
|
||||
|
||||
void fileOpenCallback()
|
||||
{
|
||||
|
||||
@@ -581,6 +592,7 @@ OpenGLExampleBrowser::OpenGLExampleBrowser(class ExampleEntries* examples)
|
||||
|
||||
OpenGLExampleBrowser::~OpenGLExampleBrowser()
|
||||
{
|
||||
deleteDemo();
|
||||
gAllExamples = 0;
|
||||
}
|
||||
|
||||
@@ -790,7 +802,7 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[])
|
||||
}
|
||||
|
||||
gui->registerFileOpenCallback(fileOpenCallback);
|
||||
|
||||
gui->registerQuitCallback(quitCallback);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user