Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Demos / OpenGL / GlutDemoApplication.cpp
1
2 #ifndef _WINDOWS
3
4 #include "GlutDemoApplication.h"
5
6 #include "GlutStuff.h"
7
8 #include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
9 #include "BulletDynamics/Dynamics/btRigidBody.h"
10
11 void    GlutDemoApplication::updateModifierKeys()
12 {
13         m_modifierKeys = 0;
14         if (glutGetModifiers() & GLUT_ACTIVE_ALT)
15                 m_modifierKeys |= BT_ACTIVE_ALT;
16
17         if (glutGetModifiers() & GLUT_ACTIVE_CTRL)
18                 m_modifierKeys |= BT_ACTIVE_CTRL;
19         
20         if (glutGetModifiers() & GLUT_ACTIVE_SHIFT)
21                 m_modifierKeys |= BT_ACTIVE_SHIFT;
22 }
23
24 void GlutDemoApplication::specialKeyboard(int key, int x, int y)        
25 {
26         (void)x;
27         (void)y;
28
29         switch (key) 
30         {
31         case GLUT_KEY_F1:
32                 {
33
34                         break;
35                 }
36
37         case GLUT_KEY_F2:
38                 {
39
40                         break;
41                 }
42
43
44         case GLUT_KEY_END:
45                 {
46                         int numObj = getDynamicsWorld()->getNumCollisionObjects();
47                         if (numObj)
48                         {
49                                 btCollisionObject* obj = getDynamicsWorld()->getCollisionObjectArray()[numObj-1];
50
51                                 getDynamicsWorld()->removeCollisionObject(obj);
52                                 btRigidBody* body = btRigidBody::upcast(obj);
53                                 if (body && body->getMotionState())
54                                 {
55                                         delete body->getMotionState();                                  
56                                 }
57                                 delete obj;
58
59
60                         }
61                         break;
62                 }
63         case GLUT_KEY_LEFT : stepLeft(); break;
64         case GLUT_KEY_RIGHT : stepRight(); break;
65         case GLUT_KEY_UP : stepFront(); break;
66         case GLUT_KEY_DOWN : stepBack(); break;
67         case GLUT_KEY_PAGE_UP : zoomIn(); break;
68         case GLUT_KEY_PAGE_DOWN : zoomOut(); break;
69         case GLUT_KEY_HOME : toggleIdle(); break;
70         default:
71                 //        std::cout << "unused (special) key : " << key << std::endl;
72                 break;
73         }
74
75         glutPostRedisplay();
76
77 }
78
79 void GlutDemoApplication::swapBuffers()
80 {
81         glutSwapBuffers();
82
83 }
84
85 #endif //_WINDOWS
86
87