diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d0bccf49..72374090a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -180,20 +180,11 @@ ELSE (OPENGL_FOUND) SET(OPENGL_glu_LIBRARY glu32) ENDIF (OPENGL_FOUND) -# ADD_DEFINITIONS(-DBT_USE_FREEGLUT) #FIND_PACKAGE(GLU) -OPTION(BUILD_BULLET2_DEMOS "Set when you want to build the Bullet 2 demos" ON) -IF(BUILD_BULLET2_DEMOS AND BUILD_OPENGL3_DEMOS) - - - IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/examples AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/examples) - SUBDIRS(examples) - ENDIF() -ENDIF(BUILD_BULLET2_DEMOS) IF (APPLE) FIND_LIBRARY(COCOA_LIBRARY Cocoa) @@ -207,6 +198,7 @@ IF(BUILD_BULLET3) IF(_CURRENT_OSX_VERSION VERSION_LESS 10.9) 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) @@ -222,8 +214,20 @@ IF(BUILD_OPENGL3_DEMOS) IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/Demos3 AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/Demos3) SUBDIRS(Demos3) ENDIF() +ELSE() + ADD_DEFINITIONS(-DNO_OPENGL3) ENDIF(BUILD_OPENGL3_DEMOS) +OPTION(BUILD_BULLET2_DEMOS "Set when you want to build the Bullet 2 demos" ON) +IF(BUILD_BULLET2_DEMOS) + + IF(EXISTS ${BULLET_PHYSICS_SOURCE_DIR}/examples AND IS_DIRECTORY ${BULLET_PHYSICS_SOURCE_DIR}/examples) + SUBDIRS(examples) + ENDIF() +ENDIF(BUILD_BULLET2_DEMOS) + + + OPTION(BUILD_EXTRAS "Set when you want to build the extras" ON) IF(BUILD_EXTRAS) SUBDIRS(Extras) diff --git a/build3/findOpenGLGlewGlut.lua b/build3/findOpenGLGlewGlut.lua index 886b6a561..6ed26e65e 100644 --- a/build3/findOpenGLGlewGlut.lua +++ b/build3/findOpenGLGlewGlut.lua @@ -29,6 +29,10 @@ configuration {"Windows"} links {"opengl32","glu32"} configuration {"MacOSX"} + if (not findOpenGL3()) then + defines {"NO_OPENGL3"} + end + links { "OpenGL.framework"} configuration {"not Windows", "not MacOSX"} if os.is("Linux") then diff --git a/build3/premake4_osx32 b/build3/premake4_osx32 new file mode 100755 index 000000000..5f5156216 Binary files /dev/null and b/build3/premake4_osx32 differ diff --git a/examples/ExampleBrowser/ExampleEntries.cpp b/examples/ExampleBrowser/ExampleEntries.cpp index 2b2b745e9..b37a7c433 100644 --- a/examples/ExampleBrowser/ExampleEntries.cpp +++ b/examples/ExampleBrowser/ExampleEntries.cpp @@ -33,9 +33,10 @@ #include "../RollingFrictionDemo/RollingFrictionDemo.h" #ifdef B3_USE_CLEW +#ifndef NO_OPENGL3 #include "../OpenCL/broadphase/PairBench.h" #include "../OpenCL/rigidbody/GpuConvexScene.h" - +#endif #endif //B3_USE_CLEW @@ -193,6 +194,7 @@ static ExampleEntry gDefaultExamples[]= }; #ifdef B3_USE_CLEW +#ifndef NO_OPENGL3 static ExampleEntry gOpenCLExamples[]= { ExampleEntry(0,"OpenCL (experimental)"), @@ -201,6 +203,7 @@ static ExampleEntry gOpenCLExamples[]= ExampleEntry(1,"Pair Bench", "Benchmark of overlapping pair search using OpenCL.", PairBenchOpenCLCreateFunc), }; +#endif #endif // static btAlignedObjectArray gAdditionalRegisteredExamples; @@ -223,11 +226,13 @@ ExampleEntries::~ExampleEntries() void ExampleEntries::initOpenCLExampleEntries() { #ifdef B3_USE_CLEW +#ifndef NO_OPENGL3 int numDefaultEntries = sizeof(gOpenCLExamples)/sizeof(ExampleEntry); for (int i=0;im_allExamples.push_back(gOpenCLExamples[i]); } +#endif #endif //B3_USE_CLEW } diff --git a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp index ce75cf208..773813a73 100644 --- a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp +++ b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp @@ -2,7 +2,9 @@ #include "LinearMath/btQuickprof.h" #include "../OpenGLWindow/OpenGLInclude.h" #include "../OpenGLWindow/SimpleOpenGL2App.h" +#ifndef NO_OPENGL3 #include "../OpenGLWindow/SimpleOpenGL3App.h" +#endif #include "../CommonInterfaces/CommonRenderInterface.h" #ifdef __APPLE__ #include "../OpenGLWindow/MacOpenGLWindow.h" @@ -60,7 +62,10 @@ static b3AlignedObjectArray allNames; static class ExampleEntries* gAllExamples=0; bool sUseOpenGL2 = false; bool drawGUI=true; +#ifndef USE_OPENGL3 extern bool useShadowMap; +#endif + static bool visualWireframe=false; static bool renderVisualGeometry=true; static bool renderGrid = true; @@ -150,12 +155,12 @@ void MyKeyboardCallback(int key, int state) { pauseSimulation = !pauseSimulation; } - +#ifndef NO_OPENGL3 if (key=='s' && state) { useShadowMap=!useShadowMap; } - +#endif if (key==B3G_ESCAPE && s_window) { s_window->setRequestExit(); @@ -598,10 +603,12 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[]) int width = 1024; int height=768; - +#ifndef NO_OPENGL3 SimpleOpenGL3App* simpleApp=0; sUseOpenGL2 =args.CheckCmdLineFlag("opengl2"); - +#else + sUseOpenGL2 = true; +#endif const char* appTitle = "Bullet Physics ExampleBrowser"; #if defined (_DEBUG) || defined (DEBUG) const char* optMode = "Debug build (slow)"; @@ -615,19 +622,22 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[]) sprintf(title,"%s using limited OpenGL2 fallback. %s", appTitle,optMode); s_app = new SimpleOpenGL2App(title,width,height); s_app->m_renderer = new SimpleOpenGL2Renderer(width,height); - } else + } +#ifndef NO_OPENGL3 + else { char title[1024]; sprintf(title,"%s using OpenGL3+. %s", appTitle,optMode); simpleApp = new SimpleOpenGL3App(title,width,height); s_app = simpleApp; } +#endif char* gVideoFileName = 0; args.GetCmdLineArgument("mp4",gVideoFileName); - + #ifndef NO_OPENGL3 if (gVideoFileName) simpleApp->dumpFramesToVideo(gVideoFileName); - + #endif s_instancingRenderer = s_app->m_renderer; s_window = s_app->m_window; @@ -658,11 +668,14 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[]) if (sUseOpenGL2 ) { gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont(); - } else + } +#ifndef NO_OPENGL3 + else { sth_stash* fontstash=simpleApp->getFontStash(); gwenRenderer = new GwenOpenGL3CoreRenderer(simpleApp->m_primRenderer,fontstash,width,height,s_window->getRetinaScale(),myTexLoader); } +#endif // gui->init(width,height,gwenRenderer,s_window->getRetinaScale()); diff --git a/examples/ExampleBrowser/premake4.lua b/examples/ExampleBrowser/premake4.lua index de359e4ff..101a4c6e0 100644 --- a/examples/ExampleBrowser/premake4.lua +++ b/examples/ExampleBrowser/premake4.lua @@ -93,7 +93,7 @@ } - if (hasCL) then + if (hasCL and findOpenGL3()) then files { "../OpenCL/broadphase/*", "../OpenCL/CommonOpenCL/*", diff --git a/examples/OpenGLWindow/GLInstancingRenderer.cpp b/examples/OpenGLWindow/GLInstancingRenderer.cpp index faae50d41..1ac543995 100644 --- a/examples/OpenGLWindow/GLInstancingRenderer.cpp +++ b/examples/OpenGLWindow/GLInstancingRenderer.cpp @@ -1,3 +1,4 @@ +#ifndef NO_OPENGL3 /* Copyright (c) 2012 Advanced Micro Devices, Inc. @@ -1641,3 +1642,4 @@ int GLInstancingRenderer::getInstanceCapacity() const { return m_data->m_maxNumObjectCapacity; } +#endif //NO_OPENGL3 diff --git a/examples/OpenGLWindow/GLPrimitiveRenderer.cpp b/examples/OpenGLWindow/GLPrimitiveRenderer.cpp index cff4bd52e..60328514e 100644 --- a/examples/OpenGLWindow/GLPrimitiveRenderer.cpp +++ b/examples/OpenGLWindow/GLPrimitiveRenderer.cpp @@ -1,3 +1,4 @@ +#ifndef NO_OPENGL3 #include "GLPrimitiveRenderer.h" #include "GLPrimInternalData.h" @@ -319,4 +320,5 @@ void GLPrimitiveRenderer::setScreenSize(int width, int height) m_screenWidth = width; m_screenHeight = height; -} \ No newline at end of file +} +#endif diff --git a/examples/OpenGLWindow/GLRenderToTexture.cpp b/examples/OpenGLWindow/GLRenderToTexture.cpp index 3ca338eba..89e044ce3 100644 --- a/examples/OpenGLWindow/GLRenderToTexture.cpp +++ b/examples/OpenGLWindow/GLRenderToTexture.cpp @@ -1,3 +1,4 @@ +#ifndef NO_OPENGL3 ///See http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-14-render-to-texture/ @@ -132,4 +133,5 @@ GLRenderToTexture::~GLRenderToTexture() glDeleteFramebuffers(1, &m_framebufferName); } } +#endif diff --git a/examples/OpenGLWindow/MacOpenGLWindow.mm b/examples/OpenGLWindow/MacOpenGLWindow.mm index 66c672ab1..4f2019570 100644 --- a/examples/OpenGLWindow/MacOpenGLWindow.mm +++ b/examples/OpenGLWindow/MacOpenGLWindow.mm @@ -2,8 +2,8 @@ #define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED #import -#include -#include +#include "OpenGLInclude.h" + #include @@ -107,16 +107,16 @@ float loop; { (*m_resizeCallback)(width,height); } - + #ifndef NO_OPENGL3 NSRect backingBounds = [self convertRectToBacking:[self bounds]]; GLsizei backingPixelWidth = (GLsizei)(backingBounds.size.width), backingPixelHeight = (GLsizei)(backingBounds.size.height); // Set viewport glViewport(0, 0, backingPixelWidth, backingPixelHeight); - - // glViewport(0,0,(GLsizei)width,(GLsizei)height); - + #else + glViewport(0,0,(GLsizei)width,(GLsizei)height); +#endif } [m_context setView: self]; @@ -140,7 +140,7 @@ float loop; - +#ifndef NO_OPENGL3 if (openglVersion==3) { NSOpenGLPixelFormatAttribute attrs[] = @@ -156,6 +156,7 @@ float loop; // Init GL context fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes: (NSOpenGLPixelFormatAttribute*)attrs]; } else +#endif { NSOpenGLPixelFormatAttribute attrs[] = { @@ -437,8 +438,11 @@ void MacOpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci) TransformProcessType(&psn, kProcessTransformToForegroundApplication); SetFrontProcess(&psn); */ - +#ifndef NO_OPENGL3 m_retinaScaleFactor = [m_internalData->m_myview convertSizeToBacking:sz].width; +#else + m_retinaScaleFactor=1.f; +#endif [m_internalData->m_myApp finishLaunching]; [pool release]; diff --git a/examples/OpenGLWindow/OpenGLInclude.h b/examples/OpenGLWindow/OpenGLInclude.h index fee6a3095..19219a188 100644 --- a/examples/OpenGLWindow/OpenGLInclude.h +++ b/examples/OpenGLWindow/OpenGLInclude.h @@ -24,7 +24,7 @@ subject to the following restrictions: //#include //#include //#import -#ifdef USE_OPENGL2 +#if defined (USE_OPENGL2) || defined (NO_OPENGL3) #include #else #include diff --git a/examples/OpenGLWindow/opengl_fontstashcallbacks.cpp b/examples/OpenGLWindow/opengl_fontstashcallbacks.cpp index 35250ce2e..18db74692 100644 --- a/examples/OpenGLWindow/opengl_fontstashcallbacks.cpp +++ b/examples/OpenGLWindow/opengl_fontstashcallbacks.cpp @@ -1,3 +1,4 @@ +#ifndef NO_OPENGL3 #include "opengl_fontstashcallbacks.h" #include "../OpenGLWindow/GLPrimitiveRenderer.h" #include "../OpenGLWindow/GLPrimInternalData.h" @@ -250,3 +251,5 @@ void dumpTextureToPng(int textureWidth, int textureHeight, const char* fileName) free(pixels); } +#endif + diff --git a/examples/Vehicles/Hinge2Vehicle.cpp b/examples/Vehicles/Hinge2Vehicle.cpp index 1ed665190..9d72ad57c 100644 --- a/examples/Vehicles/Hinge2Vehicle.cpp +++ b/examples/Vehicles/Hinge2Vehicle.cpp @@ -301,13 +301,11 @@ Hinge2Vehicle::~Hinge2Vehicle() } -extern float shadowMapWorldSize; void Hinge2Vehicle::initPhysics() { m_guiHelper->setUpAxis(1); - shadowMapWorldSize = 10; btCollisionShape* groundShape = new btBoxShape(btVector3(50,3,50)); m_collisionShapes.push_back(groundShape); diff --git a/test/GwenOpenGLTest/OpenGLSample.cpp b/test/GwenOpenGLTest/OpenGLSample.cpp index 3f1452f34..af7781fdf 100644 --- a/test/GwenOpenGLTest/OpenGLSample.cpp +++ b/test/GwenOpenGLTest/OpenGLSample.cpp @@ -2,6 +2,7 @@ #include "Gwen/Gwen.h" #include "Gwen/Skins/Simple.h" +#include "../OpenGLWindow/OpenGLInclude.h" #include "UnitTest.h" @@ -22,9 +23,10 @@ extern unsigned char OpenSansData[]; #endif//__APPLE__ #include "OpenGLWindow/opengl_fontstashcallbacks.h" - +#ifndef NO_OPENGL3 #include "OpenGLWindow/GwenOpenGL3CoreRenderer.h" #include "OpenGLWindow/GLPrimitiveRenderer.h" +#endif #include Gwen::Controls::Canvas* pCanvas = NULL; @@ -79,10 +81,12 @@ static void MyResizeCallback( float width, float height) sWidth = width; sHeight = height; // printf("resize(%d,%d)\n",sWidth,sHeight); +#ifndef NO_OPENGL3 if (primRenderer) { primRenderer->setScreenSize(width,height); } +#endif if (gwenRenderer) { gwenRenderer->Resize(width,height); @@ -96,7 +100,7 @@ static void MyResizeCallback( float width, float height) int droidRegular;//, droidItalic, droidBold, droidJapanese, dejavu; - +#ifndef NO_OPENGL3 sth_stash* initFont(GLPrimitiveRenderer* primRenderer) { GLint err; @@ -217,7 +221,7 @@ sth_stash* initFont(GLPrimitiveRenderer* primRenderer) return stash; } - +#endif void keyCallback(int key, int value) { printf("key = %d, value = %d\n", key,value); @@ -308,7 +312,11 @@ int main() b3gDefaultOpenGLWindow* window = new b3gDefaultOpenGLWindow(); window->setKeyboardCallback(keyCallback); b3gWindowConstructionInfo wci; - wci.m_openglVersion = 2; +#ifndef NO_OPENGL3 + wci.m_openglVersion = 3; +#else + wci.m_openglVersion = 2; +#endif wci.m_width = sWidth; wci.m_height = sHeight; // wci.m_resizeCallback = MyResizeCallback; @@ -333,7 +341,7 @@ int main() sprintf(title,"Gwen with OpenGL %d\n",wci.m_openglVersion); } window->setWindowTitle(title); - +#ifndef NO_OPENGL3 if (majorGlVersion>=3 && wci.m_openglVersion>=3) { float retinaScale = 1.f; @@ -363,6 +371,7 @@ int main() gwenRenderer = new GwenOpenGL3CoreRenderer(primRenderer,font,sWidth,sHeight,retinaScale); } else +#endif { //OpenGL 2.x gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont();