enable Box2dDemo for Win32 app.
This commit is contained in:
25
Demos/BasicDemo/Win32BasicDemo.cpp
Normal file
25
Demos/BasicDemo/Win32BasicDemo.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifdef _WINDOWS
|
||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
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.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "BasicDemo.h"
|
||||||
|
|
||||||
|
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
|
||||||
|
DemoApplication* createDemo()
|
||||||
|
{
|
||||||
|
return new BasicDemo();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -69,7 +69,7 @@ void Box2dDemo::clientMoveAndDisplay()
|
|||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
|
|
||||||
glutSwapBuffers();
|
swapBuffers();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ void Box2dDemo::displayCallback(void) {
|
|||||||
m_dialogDynamicsWorld->draw(0.f);
|
m_dialogDynamicsWorld->draw(0.f);
|
||||||
|
|
||||||
glFlush();
|
glFlush();
|
||||||
glutSwapBuffers();
|
swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ void Box2dDemo::reshape(int w, int h)
|
|||||||
{
|
{
|
||||||
if (m_dialogDynamicsWorld)
|
if (m_dialogDynamicsWorld)
|
||||||
m_dialogDynamicsWorld->setScreenSize(w,h);
|
m_dialogDynamicsWorld->setScreenSize(w,h);
|
||||||
GlutDemoApplication::reshape(w,h);
|
PlatformDemoApplication::reshape(w,h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box2dDemo::initPhysics()
|
void Box2dDemo::initPhysics()
|
||||||
@@ -210,20 +210,20 @@ void Box2dDemo::initPhysics()
|
|||||||
//create a few dynamic rigidbodies
|
//create a few dynamic rigidbodies
|
||||||
// Re-using the same collision is better for memory usage and performance
|
// Re-using the same collision is better for memory usage and performance
|
||||||
|
|
||||||
btScalar u = 1*SCALING-0.04;
|
btScalar u= btScalar(1*SCALING-0.04);
|
||||||
btVector3 points[3] = {btVector3(0,u,0),btVector3(-u,-u,0),btVector3(u,-u,0)};
|
btVector3 points[3] = {btVector3(0,u,0),btVector3(-u,-u,0),btVector3(u,-u,0)};
|
||||||
btConvexShape* colShape= new btConvex2dShape(new btBoxShape(btVector3(SCALING*1,SCALING*1,0.04)));
|
btConvexShape* colShape= new btConvex2dShape(new btBoxShape(btVector3(btScalar(SCALING*1),btScalar(SCALING*1),btScalar(0.04))));
|
||||||
//btCollisionShape* colShape = new btBox2dShape(btVector3(SCALING*1,SCALING*1,0.04));
|
//btCollisionShape* colShape = new btBox2dShape(btVector3(SCALING*1,SCALING*1,0.04));
|
||||||
|
|
||||||
btConvexShape* colShape2= new btConvex2dShape(new btConvexHullShape(&points[0].getX(),3));
|
btConvexShape* colShape2= new btConvex2dShape(new btConvexHullShape(&points[0].getX(),3));
|
||||||
btConvexShape* colShape3= new btConvex2dShape(new btCylinderShapeZ(btVector3(SCALING*1,SCALING*1,0.04)));
|
btConvexShape* colShape3= new btConvex2dShape(new btCylinderShapeZ(btVector3(btScalar(SCALING*1),btScalar(SCALING*1),btScalar(0.04))));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//btUniformScalingShape* colShape = new btUniformScalingShape(convexColShape,1.f);
|
//btUniformScalingShape* colShape = new btUniformScalingShape(convexColShape,1.f);
|
||||||
colShape->setMargin(0.03);
|
colShape->setMargin(btScalar(0.03));
|
||||||
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
|
||||||
m_collisionShapes.push_back(colShape);
|
m_collisionShapes.push_back(colShape);
|
||||||
m_collisionShapes.push_back(colShape2);
|
m_collisionShapes.push_back(colShape2);
|
||||||
|
|||||||
@@ -15,7 +15,14 @@ subject to the following restrictions:
|
|||||||
#ifndef BOX2D_DEMO_H
|
#ifndef BOX2D_DEMO_H
|
||||||
#define BOX2D_DEMO_H
|
#define BOX2D_DEMO_H
|
||||||
|
|
||||||
|
#ifdef _WINDOWS
|
||||||
|
#include "Win32DemoApplication.h"
|
||||||
|
#define PlatformDemoApplication Win32DemoApplication
|
||||||
|
#else
|
||||||
#include "GlutDemoApplication.h"
|
#include "GlutDemoApplication.h"
|
||||||
|
#define PlatformDemoApplication GlutDemoApplication
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "LinearMath/btAlignedObjectArray.h"
|
#include "LinearMath/btAlignedObjectArray.h"
|
||||||
|
|
||||||
class btBroadphaseInterface;
|
class btBroadphaseInterface;
|
||||||
@@ -28,7 +35,7 @@ class btDefaultCollisionConfiguration;
|
|||||||
class GL_DialogDynamicsWorld;
|
class GL_DialogDynamicsWorld;
|
||||||
|
|
||||||
///Box2dDemo is good starting point for learning the code base and porting.
|
///Box2dDemo is good starting point for learning the code base and porting.
|
||||||
class Box2dDemo : public GlutDemoApplication
|
class Box2dDemo : public PlatformDemoApplication
|
||||||
{
|
{
|
||||||
|
|
||||||
//keep the collision shapes, for deletion/cleanup
|
//keep the collision shapes, for deletion/cleanup
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ INCLUDE_DIRECTORIES(
|
|||||||
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
|
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IF (USE_GLUT)
|
||||||
LINK_LIBRARIES(
|
LINK_LIBRARIES(
|
||||||
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
|
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
|
||||||
)
|
)
|
||||||
@@ -24,5 +25,17 @@ ADD_EXECUTABLE(AppBox2dDemo
|
|||||||
Box2dDemo.cpp
|
Box2dDemo.cpp
|
||||||
Box2dDemo.h
|
Box2dDemo.h
|
||||||
)
|
)
|
||||||
|
ELSE (USE_GLUT)
|
||||||
|
LINK_LIBRARIES(
|
||||||
|
OpenGLSupport BulletDynamics BulletCollision LinearMath ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
|
||||||
|
)
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(AppBox2dDemo
|
||||||
|
WIN32
|
||||||
|
../OpenGL/Win32AppMain.cpp
|
||||||
|
Win32Box2dDemo.cpp
|
||||||
|
Box2dDemo.cpp
|
||||||
|
Box2dDemo.h
|
||||||
|
)
|
||||||
|
ENDIF (USE_GLUT)
|
||||||
|
|
||||||
|
|||||||
25
Demos/Box2dDemo/Win32Box2dDemo.cpp
Normal file
25
Demos/Box2dDemo/Win32Box2dDemo.cpp
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifdef _WINDOWS
|
||||||
|
/*
|
||||||
|
Bullet Continuous Collision Detection and Physics Library
|
||||||
|
Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied warranty.
|
||||||
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it freely,
|
||||||
|
subject to the following restrictions:
|
||||||
|
|
||||||
|
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.
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||||
|
3. This notice may not be removed or altered from any source distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Box2dDemo.h"
|
||||||
|
|
||||||
|
///The 'createDemo' function is called from Bullet/Demos/OpenGL/Win32AppMain.cpp to instantiate this particular demo
|
||||||
|
DemoApplication* createDemo()
|
||||||
|
{
|
||||||
|
return new Box2dDemo();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
SUBDIRS( OpenGL BasicDemo Benchmarks)
|
SUBDIRS( OpenGL BasicDemo Benchmarks Box2dDemo)
|
||||||
|
|
||||||
|
|
||||||
#todo: re-enable the rest of the demos again
|
#todo: re-enable the rest of the demos again
|
||||||
|
|||||||
Reference in New Issue
Block a user