Imported Upstream version 2.81
[platform/upstream/libbullet.git] / Demos / Gpu2dDemo / BasicDemo.h
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 #ifndef BASIC_DEMO_H
16 #define BASIC_DEMO_H
17
18 #include "DemoApplication.h"
19 #include "LinearMath/btAlignedObjectArray.h"
20 #include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
21
22
23 #ifdef BT_USE_CUDA
24 //#include "btCudaDemoPairCache.h"
25 //#include <vector_types.h>
26 #endif //BT_USE_CUDA
27
28 class btBroadphaseInterface;
29 class btCollisionShape;
30 class btOverlappingPairCache;
31 class btCollisionDispatcher;
32 class btConstraintSolver;
33 struct btCollisionAlgorithmCreateFunc;
34 class btDefaultCollisionConfiguration;
35 #include "GlutDemoApplication.h"
36
37 ///BasicDemo is good starting point for learning the code base and porting.
38 class BasicDemo : public GlutDemoApplication
39 {
40
41         //keep the collision shapes, for deletion/cleanup
42         btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
43
44         btBroadphaseInterface*  m_broadphase;
45
46         btCollisionDispatcher*  m_dispatcher;
47
48         btConstraintSolver*     m_solver;
49
50         btDefaultCollisionConfiguration* m_collisionConfiguration;
51
52         int m_mouseButtons;
53         int m_mouseOldX;
54         int m_mouseOldY;
55
56         public:
57
58         BasicDemo()
59         {
60         }
61         virtual ~BasicDemo()
62         {
63                 exitPhysics();
64         }
65         void    initPhysics();
66
67         void    exitPhysics();
68
69         ///don't shoot a box in this demo ;-)
70         virtual void    shootBox(const btVector3& dest) {}
71
72         virtual void clientMoveAndDisplay();
73
74         virtual void displayCallback();
75
76         virtual void keyboardCallback(unsigned char key, int x, int y);
77
78         virtual void clientResetScene();
79
80         static DemoApplication* Create()
81         {
82                 BasicDemo* demo = new BasicDemo;
83                 demo->myinit();
84                 demo->initPhysics();
85                 demo->m_mouseButtons = 0;
86                 demo->m_mouseOldX = 0;
87                 demo->m_mouseOldY = 0;
88                 return demo;
89         }
90
91         void DrawConstraintInfo();
92         void outputDebugInfo(int & xOffset,int & yStart, int  yIncr);
93         virtual void renderme();
94         void addCollisionShape(btCollisionShape* pShape) { m_collisionShapes.push_back(pShape); }
95 };
96
97
98 #endif //BASIC_DEMO_H
99