[167] | 1 | /* |
---|
| 2 | Bullet Continuous Collision Detection and Physics Library |
---|
| 3 | Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ |
---|
| 4 | |
---|
| 5 | This software is provided 'as-is', without any express or implied warranty. |
---|
| 6 | In no event will the authors be held liable for any damages arising from the use of this software. |
---|
| 7 | Permission is granted to anyone to use this software for any purpose, |
---|
| 8 | including commercial applications, and to alter it and redistribute it freely, |
---|
| 9 | subject to the following restrictions: |
---|
| 10 | |
---|
| 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. |
---|
| 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. |
---|
| 13 | 3. This notice may not be removed or altered from any source distribution. |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | #include "DemoApplication.h" |
---|
| 18 | |
---|
| 19 | //glut is C code, this global gDemoApplication links glut to the C++ demo |
---|
| 20 | static DemoApplication* gDemoApplication = 0; |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | #include "GlutStuff.h" |
---|
| 24 | |
---|
| 25 | static void glutKeyboardCallback(unsigned char key, int x, int y) |
---|
| 26 | { |
---|
| 27 | gDemoApplication->keyboardCallback(key,x,y); |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | static void glutKeyboardUpCallback(unsigned char key, int x, int y) |
---|
| 31 | { |
---|
| 32 | gDemoApplication->keyboardUpCallback(key,x,y); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | static void glutSpecialKeyboardCallback(int key, int x, int y) |
---|
| 36 | { |
---|
| 37 | gDemoApplication->specialKeyboard(key,x,y); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | static void glutSpecialKeyboardUpCallback(int key, int x, int y) |
---|
| 41 | { |
---|
| 42 | gDemoApplication->specialKeyboardUp(key,x,y); |
---|
| 43 | } |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | static void glutReshapeCallback(int w, int h) |
---|
| 47 | { |
---|
| 48 | gDemoApplication->reshape(w,h); |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | static void glutMoveAndDisplayCallback() |
---|
| 52 | { |
---|
| 53 | gDemoApplication->moveAndDisplay(); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | static void glutMouseFuncCallback(int button, int state, int x, int y) |
---|
| 57 | { |
---|
| 58 | gDemoApplication->mouseFunc(button,state,x,y); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | |
---|
| 62 | static void glutMotionFuncCallback(int x,int y) |
---|
| 63 | { |
---|
| 64 | gDemoApplication->mouseMotionFunc(x,y); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | static void glutDisplayCallback(void) |
---|
| 69 | { |
---|
| 70 | gDemoApplication->displayCallback(); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | int glutmain(int argc, char **argv,int width,int height,const char* title,DemoApplication* demoApp) { |
---|
| 75 | |
---|
| 76 | gDemoApplication = demoApp; |
---|
| 77 | |
---|
| 78 | glutInit(&argc, argv); |
---|
| 79 | glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_STENCIL); |
---|
| 80 | glutInitWindowPosition(0, 0); |
---|
| 81 | glutInitWindowSize(width, height); |
---|
| 82 | glutCreateWindow(title); |
---|
| 83 | #ifdef BT_USE_FREEGLUT |
---|
| 84 | glutSetOption (GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS); |
---|
| 85 | #endif |
---|
| 86 | |
---|
| 87 | gDemoApplication->myinit(); |
---|
| 88 | |
---|
| 89 | glutKeyboardFunc(glutKeyboardCallback); |
---|
| 90 | glutKeyboardUpFunc(glutKeyboardUpCallback); |
---|
| 91 | glutSpecialFunc(glutSpecialKeyboardCallback); |
---|
| 92 | glutSpecialUpFunc(glutSpecialKeyboardUpCallback); |
---|
| 93 | |
---|
| 94 | glutReshapeFunc(glutReshapeCallback); |
---|
| 95 | //createMenu(); |
---|
| 96 | glutIdleFunc(glutMoveAndDisplayCallback); |
---|
| 97 | glutMouseFunc(glutMouseFuncCallback); |
---|
| 98 | glutMotionFunc(glutMotionFuncCallback); |
---|
| 99 | glutDisplayFunc( glutDisplayCallback ); |
---|
| 100 | |
---|
| 101 | glutMoveAndDisplayCallback(); |
---|
| 102 | |
---|
| 103 | glutMainLoop(); |
---|
| 104 | return 0; |
---|
| 105 | } |
---|
| 106 | |
---|
| 107 | |
---|