enable Box2dDemo for Win32 app.

This commit is contained in:
erwin.coumans
2010-01-19 23:37:14 +00:00
parent 8da244b443
commit 9bcc19a98f
6 changed files with 87 additions and 17 deletions

View 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

View File

@@ -69,7 +69,7 @@ void Box2dDemo::clientMoveAndDisplay()
glFlush();
glutSwapBuffers();
swapBuffers();
}
@@ -89,7 +89,7 @@ void Box2dDemo::displayCallback(void) {
m_dialogDynamicsWorld->draw(0.f);
glFlush();
glutSwapBuffers();
swapBuffers();
}
@@ -98,7 +98,7 @@ void Box2dDemo::reshape(int w, int h)
{
if (m_dialogDynamicsWorld)
m_dialogDynamicsWorld->setScreenSize(w,h);
GlutDemoApplication::reshape(w,h);
PlatformDemoApplication::reshape(w,h);
}
void Box2dDemo::initPhysics()
@@ -210,20 +210,20 @@ void Box2dDemo::initPhysics()
//create a few dynamic rigidbodies
// 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)};
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));
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);
colShape->setMargin(0.03);
colShape->setMargin(btScalar(0.03));
//btCollisionShape* colShape = new btSphereShape(btScalar(1.));
m_collisionShapes.push_back(colShape);
m_collisionShapes.push_back(colShape2);

View File

@@ -15,7 +15,14 @@ subject to the following restrictions:
#ifndef BOX2D_DEMO_H
#define BOX2D_DEMO_H
#ifdef _WINDOWS
#include "Win32DemoApplication.h"
#define PlatformDemoApplication Win32DemoApplication
#else
#include "GlutDemoApplication.h"
#define PlatformDemoApplication GlutDemoApplication
#endif
#include "LinearMath/btAlignedObjectArray.h"
class btBroadphaseInterface;
@@ -28,7 +35,7 @@ class btDefaultCollisionConfiguration;
class GL_DialogDynamicsWorld;
///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

View File

@@ -15,6 +15,7 @@ INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
)
IF (USE_GLUT)
LINK_LIBRARIES(
OpenGLSupport BulletDynamics BulletCollision LinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY}
)
@@ -24,5 +25,17 @@ ADD_EXECUTABLE(AppBox2dDemo
Box2dDemo.cpp
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)

View 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

View File

@@ -1,4 +1,4 @@
SUBDIRS( OpenGL BasicDemo Benchmarks)
SUBDIRS( OpenGL BasicDemo Benchmarks Box2dDemo)
#todo: re-enable the rest of the demos again