From 954d4887568584c71868d53984fc1f0893b4033c Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Fri, 22 Aug 2014 14:41:21 -0700 Subject: [PATCH] cmake+premake disable OpenGL 3 demos on Mac OSX versions below 10.9 See also http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?f=9&t=10073 Move ConstraintPhysicsSetup to Demos3/bullet3/ConstraintDemo --- CMakeLists.txt | 22 ++++-- Demos/ConstraintDemo/CMakeLists.txt | 2 +- .../ConstraintDemo/ConstraintPhysicsSetup.cpp | 72 ------------------- Demos/ConstraintDemo/ConstraintPhysicsSetup.h | 16 ----- Demos3/AllBullet2Demos/BulletDemoEntries.h | 2 +- Demos3/AllBullet2Demos/CMakeLists.txt | 4 +- Demos3/AllBullet2Demos/premake4.lua | 4 +- Demos3/CMakeLists.txt | 4 +- build3/findOpenGLGlewGlut.lua | 17 +++++ build3/premake4.lua | 25 ++++--- 10 files changed, 59 insertions(+), 109 deletions(-) delete mode 100644 Demos/ConstraintDemo/ConstraintPhysicsSetup.cpp delete mode 100644 Demos/ConstraintDemo/ConstraintPhysicsSetup.h diff --git a/CMakeLists.txt b/CMakeLists.txt index eebc38e67..459d0c007 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,18 +231,30 @@ IF (APPLE) ENDIF() OPTION(BUILD_BULLET3 "Set when you want to build Bullet 3" ON) + IF(BUILD_BULLET3) - OPTION(BUILD_BULLET3_DEMOS "Set when you want to build the Bullet 3 demos" ON) + IF(APPLE) + MESSAGE("Mac OSX Version is ${_CURRENT_OSX_VERSION}") + IF(_CURRENT_OSX_VERSION VERSION_LESS 10.10) + MESSAGE("Mac OSX below 10.9 has no OpenGL 3 support so please disable the BUILD_OPENGL3_DEMOS option") + #unset(BUILD_OPENGL3_DEMOS CACHE) + OPTION(BUILD_OPENGL3_DEMOS "Set when you want to build the OpenGL3+ demos" OFF) + ELSE() + OPTION(BUILD_OPENGL3_DEMOS "Set when you want to build the OpenGL3+ demos" ON) + ENDIF() + ELSE() + OPTION(BUILD_OPENGL3_DEMOS "Set when you want to build Bullet 3 OpenGL3+ demos" ON) + ENDIF() ELSE(BUILD_BULLET3) - unset(BUILD_BULLET3_DEMOS CACHE) - OPTION(BUILD_BULLET3_DEMOS "Set when you want to build the Bullet 3 demos" OFF) + unset(BUILD_OPENGL3_DEMOS CACHE) + OPTION(BUILD_OPENGL3_DEMOS "Set when you want to build Bullet 3 OpenGL3+ demos" OFF) ENDIF(BUILD_BULLET3) -IF(BUILD_BULLET3_DEMOS) +IF(BUILD_OPENGL3_DEMOS) IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/Demos3 AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/Demos3) SUBDIRS(Demos3) SUBDIRS(btgui) ENDIF() -ENDIF(BUILD_BULLET3_DEMOS) +ENDIF(BUILD_OPENGL3_DEMOS) OPTION(BUILD_EXTRAS "Set when you want to build the extras" ON) IF(BUILD_EXTRAS) diff --git a/Demos/ConstraintDemo/CMakeLists.txt b/Demos/ConstraintDemo/CMakeLists.txt index d43a3bfa4..6051a2455 100644 --- a/Demos/ConstraintDemo/CMakeLists.txt +++ b/Demos/ConstraintDemo/CMakeLists.txt @@ -49,4 +49,4 @@ IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) SET_TARGET_PROPERTIES(AppConstraintDemo PROPERTIES DEBUG_POSTFIX "_Debug") SET_TARGET_PROPERTIES(AppConstraintDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel") SET_TARGET_PROPERTIES(AppConstraintDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo") -ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) \ No newline at end of file +ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES) diff --git a/Demos/ConstraintDemo/ConstraintPhysicsSetup.cpp b/Demos/ConstraintDemo/ConstraintPhysicsSetup.cpp deleted file mode 100644 index 8299d9d86..000000000 --- a/Demos/ConstraintDemo/ConstraintPhysicsSetup.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "ConstraintPhysicsSetup.h" - -ConstraintPhysicsSetup::ConstraintPhysicsSetup() -{ -} -ConstraintPhysicsSetup::~ConstraintPhysicsSetup() -{ -} - -btScalar val; -btHingeAccumulatedAngleConstraint* spDoorHinge=0; -void ConstraintPhysicsSetup::stepSimulation(float deltaTime) -{ - val=spDoorHinge->getAccumulatedHingeAngle()*SIMD_DEGS_PER_RAD;// spDoorHinge->getHingeAngle()*SIMD_DEGS_PER_RAD; - if (m_dynamicsWorld) - { - m_dynamicsWorld->stepSimulation(deltaTime); - } -} - - - -void ConstraintPhysicsSetup::initPhysics(GraphicsPhysicsBridge& gfxBridge) -{ - gfxBridge.setUpAxis(1); - - createEmptyDynamicsWorld(); - - gfxBridge.createPhysicsDebugDrawer(m_dynamicsWorld); -int mode = btIDebugDraw::DBG_DrawWireframe - +btIDebugDraw::DBG_DrawConstraints - +btIDebugDraw::DBG_DrawConstraintLimits; - m_dynamicsWorld->getDebugDrawer()->setDebugMode(mode); - -val=1.f; - SliderParams slider("hinge angle",&val); -slider.m_minVal=-720; -slider.m_maxVal=720; - gfxBridge.getParameterInterface()->registerSliderFloatParameter(slider); - - - { // create a door using hinge constraint attached to the world - btCollisionShape* pDoorShape = new btBoxShape(btVector3(2.0f, 5.0f, 0.2f)); - m_collisionShapes.push_back(pDoorShape); - btTransform doorTrans; - doorTrans.setIdentity(); - doorTrans.setOrigin(btVector3(-5.0f, -2.0f, 0.0f)); - btRigidBody* pDoorBody = createRigidBody( 1.0, doorTrans, pDoorShape); - pDoorBody->setActivationState(DISABLE_DEACTIVATION); - const btVector3 btPivotA(10.f + 2.1f, -2.0f, 0.0f ); // right next to the door slightly outside - btVector3 btAxisA( 0.0f, 1.0f, 0.0f ); // pointing upwards, aka Y-axis - - spDoorHinge = new btHingeAccumulatedAngleConstraint( *pDoorBody, btPivotA, btAxisA ); - -// spDoorHinge->setLimit( 0.0f, SIMD_PI_2 ); - // test problem values -// spDoorHinge->setLimit( -SIMD_PI, SIMD_PI*0.8f); - -// spDoorHinge->setLimit( 1.f, -1.f); -// spDoorHinge->setLimit( -SIMD_PI*0.8f, SIMD_PI); -// spDoorHinge->setLimit( -SIMD_PI*0.8f, SIMD_PI, 0.9f, 0.3f, 0.0f); -// spDoorHinge->setLimit( -SIMD_PI*0.8f, SIMD_PI, 0.9f, 0.01f, 0.0f); // "sticky limits" - // spDoorHinge->setLimit( -SIMD_PI * 0.25f, SIMD_PI * 0.25f ); -// spDoorHinge->setLimit( 0.0f, 0.0f ); - m_dynamicsWorld->addConstraint(spDoorHinge); - spDoorHinge->setDbgDrawSize(btScalar(5.f)); - - //doorTrans.setOrigin(btVector3(-5.0f, 2.0f, 0.0f)); - //btRigidBody* pDropBody = localCreateRigidBody( 10.0, doorTrans, shape); - } - -} \ No newline at end of file diff --git a/Demos/ConstraintDemo/ConstraintPhysicsSetup.h b/Demos/ConstraintDemo/ConstraintPhysicsSetup.h deleted file mode 100644 index e85853cb8..000000000 --- a/Demos/ConstraintDemo/ConstraintPhysicsSetup.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef CONSTAINT_PHYSICS_SETUP_H -#define CONSTAINT_PHYSICS_SETUP_H - -#include "../CommonRigidBodySetup.h" - -struct ConstraintPhysicsSetup : public CommonRigidBodySetup -{ - ConstraintPhysicsSetup(); - virtual ~ConstraintPhysicsSetup(); - virtual void initPhysics(GraphicsPhysicsBridge& gfxBridge); - - virtual void stepSimulation(float deltaTime); - -}; - -#endif //CONSTAINT_PHYSICS_SETUP_H diff --git a/Demos3/AllBullet2Demos/BulletDemoEntries.h b/Demos3/AllBullet2Demos/BulletDemoEntries.h index cdff06227..17caecf91 100644 --- a/Demos3/AllBullet2Demos/BulletDemoEntries.h +++ b/Demos3/AllBullet2Demos/BulletDemoEntries.h @@ -14,7 +14,7 @@ #include "../bullet2/LuaDemo/LuaPhysicsSetup.h" #include "../bullet2/ChainDemo/ChainDemo.h" #include "../../Demos/CcdPhysicsDemo/CcdPhysicsSetup.h" -#include "../../Demos/ConstraintDemo/ConstraintPhysicsSetup.h" +#include "../bullet2/ConstraintDemo/ConstraintPhysicsSetup.h" #include "../ImportURDFDemo/ImportURDFSetup.h" #include "../ImportObjDemo/ImportObjSetup.h" #include "../ImportSTLDemo/ImportSTLSetup.h" diff --git a/Demos3/AllBullet2Demos/CMakeLists.txt b/Demos3/AllBullet2Demos/CMakeLists.txt index 3e23d56fc..1dcf575e4 100644 --- a/Demos3/AllBullet2Demos/CMakeLists.txt +++ b/Demos3/AllBullet2Demos/CMakeLists.txt @@ -25,8 +25,8 @@ SET(App_AllBullet2Demos_SRCS ../../Demos/BasicDemo/BasicDemoPhysicsSetup.h ../../Demos/CcdPhysicsDemo/CcdPhysicsSetup.cpp ../../Demos/CcdPhysicsDemo/CcdPhysicsSetup.h - ../../Demos/ConstraintDemo/ConstraintPhysicsSetup.cpp - ../../Demos/ConstraintDemo/ConstraintPhysicsSetup.h + ../bullet2/ConstraintDemo/ConstraintPhysicsSetup.cpp + ../bullet2/ConstraintDemo/ConstraintPhysicsSetup.h ../bullet2/FeatherstoneMultiBodyDemo/BulletMultiBodyDemos.cpp ../bullet2/FeatherstoneMultiBodyDemo/BulletMultiBodyDemos.h ../bullet2/FeatherstoneMultiBodyDemo/MultiDofDemo.cpp diff --git a/Demos3/AllBullet2Demos/premake4.lua b/Demos3/AllBullet2Demos/premake4.lua index dcf3466b3..cbd39d96d 100644 --- a/Demos3/AllBullet2Demos/premake4.lua +++ b/Demos3/AllBullet2Demos/premake4.lua @@ -50,8 +50,8 @@ "../../Demos/BasicDemo/BasicDemoPhysicsSetup.h", "../../Demos/CcdPhysicsDemo/CcdPhysicsSetup.cpp", "../../Demos/CcdPhysicsDemo/CcdPhysicsSetup.h", - "../../Demos/ConstraintDemo/ConstraintPhysicsSetup.cpp", - "../../Demos/ConstraintDemo/ConstraintPhysicsSetup.h", + "../bullet2/ConstraintDemo/ConstraintPhysicsSetup.cpp", + "../bullet2/ConstraintDemo/ConstraintPhysicsSetup.h", "../ImportURDFDemo/ImportURDFSetup.cpp", "../ImportObjDemo/ImportObjSetup.cpp", "../ImportSTLDemo/ImportSTLSetup.cpp", diff --git a/Demos3/CMakeLists.txt b/Demos3/CMakeLists.txt index 8984fe27c..21d271b99 100644 --- a/Demos3/CMakeLists.txt +++ b/Demos3/CMakeLists.txt @@ -1,5 +1,5 @@ if (OPENGL_FOUND) -if (BUILD_BULLET3_DEMOS) +if (BUILD_OPENGL3_DEMOS) SUBDIRS( AllBullet2Demos GpuDemos SimpleOpenGL3 ) -endif(BUILD_BULLET3_DEMOS) +endif(BUILD_OPENGL3_DEMOS) endif(OPENGL_FOUND) diff --git a/build3/findOpenGLGlewGlut.lua b/build3/findOpenGLGlewGlut.lua index d2b495a00..e60a1d90d 100644 --- a/build3/findOpenGLGlewGlut.lua +++ b/build3/findOpenGLGlewGlut.lua @@ -1,3 +1,4 @@ + function findOpenGL() configuration{} if os.is("Linux") then @@ -7,6 +8,22 @@ return true end + function findOpenGL3() + configuration{} + if os.is("MacOSX") then + local osversion = os.getversion() + --Mac OSX 10.9 and above supports OpenGL 3, below doesn't, so ... + if osversion.majorversion > 10 or (osversion.majorversion == 10 and osversion.minorversion >=9) then + return findOpenGL() + else + return false + end + else + return findOpenGL() + end + end + + function initOpenGL() configuration {} configuration {"Windows"} diff --git a/build3/premake4.lua b/build3/premake4.lua index e0b9c72fe..97c092c82 100644 --- a/build3/premake4.lua +++ b/build3/premake4.lua @@ -1,6 +1,12 @@ solution "0_Bullet3Solution" + local osversion = os.getversion() + print(string.format(" %d.%d.%d (%s)", + osversion.majorversion, osversion.minorversion, osversion.revision, + osversion.description)) + + -- Multithreaded compiling if _ACTION == "vs2010" or _ACTION=="vs2008" then buildoptions { "/MP" } @@ -35,8 +41,8 @@ newoption { - trigger = "bullet2gpu", - description = "Enable Bullet 2.x GPU using b3GpuDynamicsWorld bridge to Bullet 3.x" + trigger = "bullet2demos", + description = "Compile the Bullet 2 demos (Demo/Extra folder)" } newoption @@ -113,13 +119,12 @@ include "../test/TestBullet3OpenCL" end -if findOpenGL() then +if findOpenGL3() then include "../Demos3/AllBullet2Demos" include "../Demos3/GpuDemos" include"../Demos3/BasicDemoConsole" include"../Demos3/BasicDemoCustomOpenGL2" - - + include "../btgui/OpenGLTrueTypeFont" -- include "../Demos3/CpuDemos" -- include "../Demos3/Wavefront" @@ -137,6 +142,7 @@ if findOpenGL() then include "../btgui/GwenOpenGLTest" end + -- include "../demo/gpudemo" if _OPTIONS["midi"] then include "../btgui/MidiTest" @@ -169,7 +175,7 @@ end -- include "../demo/gpu_initialize" -- include "../opencl/lds_bank_conflict" -- include "../opencl/reduce" - include "../btgui/OpenGLTrueTypeFont" +-- include "../btgui/OpenGLTrueTypeFont" -- include "../btgui/OpenGLWindow" -- include "../demo/ObjLoader" -- include "../test/b3DynamicBvhBroadphase" @@ -180,7 +186,10 @@ end include "../test/enet/client" end - - if _OPTIONS["bullet2gpu"] then + if _OPTIONS["bullet2demos"] then + include "../Extras" + if findOpenGL() then + include "../Demos" + end end