diff --git a/Demos/AllBulletDemos/Main.cpp b/Demos/AllBulletDemos/Main.cpp index 2dc3742af..5157eba69 100644 --- a/Demos/AllBulletDemos/Main.cpp +++ b/Demos/AllBulletDemos/Main.cpp @@ -225,6 +225,10 @@ void MouseMotion(int x, int y) demo->mouseMotionFunc(x,y); } +#if (defined (WIN32) && defined (_MSC_VER)) +#include "GL/freeglut_ext.h" +#endif + int main(int argc, char** argv) { @@ -237,8 +241,9 @@ int main(int argc, char** argv) glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE |GLUT_DEPTH); glutInitWindowSize(width, height); mainWindow = glutCreateWindow("http://bulletphysics.com"); - //glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); - +#if (defined (WIN32) && defined (_MSC_VER)) + glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); +#endif entry = g_demoEntries + testIndex; demo = CreatDemo(entry); diff --git a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp index 401783e27..d0de10c43 100644 --- a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp +++ b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp @@ -649,6 +649,7 @@ void CcdPhysicsDemo::exitPhysics() for (int j=0;jgetDynamicsWorld()->setDebugDrawer(&gDebugDrawer); - return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",ccdDemo); + glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bullet.sf.net",ccdDemo); + + delete ccdDemo; + } diff --git a/Demos/OpenGL/DemoApplication.cpp b/Demos/OpenGL/DemoApplication.cpp index dff36d663..0bfefad18 100644 --- a/Demos/OpenGL/DemoApplication.cpp +++ b/Demos/OpenGL/DemoApplication.cpp @@ -235,8 +235,6 @@ void DemoApplication::reshape(int w, int h) } - - void DemoApplication::keyboardCallback(unsigned char key, int x, int y) { (void)x; @@ -257,7 +255,14 @@ void DemoApplication::keyboardCallback(unsigned char key, int x, int y) switch (key) { - case 'q' : exit(0); break; + case 'q' : +#if (defined (WIN32) && defined (_MSC_VER)) + //return from glutMainLoop(), detect memory leaks etc. + glutLeaveMainLoop(); +#else + exit(); +#endif + break; case 'l' : stepLeft(); break; case 'r' : stepRight(); break; diff --git a/Demos/OpenGL/DemoApplication.h b/Demos/OpenGL/DemoApplication.h index bd5f6e673..8327b95f8 100644 --- a/Demos/OpenGL/DemoApplication.h +++ b/Demos/OpenGL/DemoApplication.h @@ -17,18 +17,7 @@ subject to the following restrictions: #define DEMO_APPLICATION_H -#ifdef WIN32//for glut.h -#include -#endif - -//think different -#if defined(__APPLE__) && !defined (VMDMESA) -#include -#include -#include -#else -#include -#endif +#include "GlutStuff.h" #include #include diff --git a/Demos/OpenGL/GlutStuff.cpp b/Demos/OpenGL/GlutStuff.cpp index 65a603aea..3651eea57 100644 --- a/Demos/OpenGL/GlutStuff.cpp +++ b/Demos/OpenGL/GlutStuff.cpp @@ -66,7 +66,6 @@ static void glutDisplayCallback(void) } - int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp) { gDemoApplication = demoApp; @@ -76,7 +75,10 @@ int glutmain(int argc, char **argv,int width,int height,const char* title,DemoAp glutInitWindowPosition(0, 0); glutInitWindowSize(width, height); glutCreateWindow(title); - +#if (defined (WIN32) && defined (_MSC_VER)) + glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); +#endif + gDemoApplication->myinit(); glutKeyboardFunc(glutKeyboardCallback); diff --git a/Demos/OpenGL/GlutStuff.h b/Demos/OpenGL/GlutStuff.h index 1ee2ba7d1..0c9ec0111 100644 --- a/Demos/OpenGL/GlutStuff.h +++ b/Demos/OpenGL/GlutStuff.h @@ -15,6 +15,24 @@ subject to the following restrictions: #ifndef GLUT_STUFF_H #define GLUT_STUFF_H +#ifdef WIN32//for glut.h +#include +#endif + +//think different +#if defined(__APPLE__) && !defined (VMDMESA) +#include +#include +#include +#else +#include +#endif + +#if (defined (WIN32) && defined (_MSC_VER)) +#include "GL/freeglut_ext.h" //to be able to return from glutMainLoop() +#endif + + class DemoApplication; int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp); diff --git a/src/LinearMath/btPoolAllocator.h b/src/LinearMath/btPoolAllocator.h index 69105dc87..ce06e1d38 100755 --- a/src/LinearMath/btPoolAllocator.h +++ b/src/LinearMath/btPoolAllocator.h @@ -77,7 +77,7 @@ public: return false; } - void free(void* ptr) + void freeMemory(void* ptr) { if (ptr) { btAssert((unsigned char*)ptr >= m_pool && (unsigned char*)ptr < m_pool + m_maxElements * m_elemSize);