allow to compile and run the ExampleBrowser on older Mac OSX versions (without OpenGL3)

using the 'NO_OPENGL3' preprocessor definition
both premake/cmake has support for this now
needs some testing
This commit is contained in:
Erwin Coumans
2015-05-06 10:35:14 -07:00
parent c2006f31e4
commit 0da584a42d
14 changed files with 82 additions and 36 deletions

View File

@@ -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<ExampleEntry> 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;i<numDefaultEntries;i++)
{
m_data->m_allExamples.push_back(gOpenCLExamples[i]);
}
#endif
#endif //B3_USE_CLEW
}

View File

@@ -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<const char*> 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());

View File

@@ -93,7 +93,7 @@
}
if (hasCL) then
if (hasCL and findOpenGL3()) then
files {
"../OpenCL/broadphase/*",
"../OpenCL/CommonOpenCL/*",

View File

@@ -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

View File

@@ -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;
}
}
#endif

View File

@@ -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

View File

@@ -2,8 +2,8 @@
#define GL_DO_NOT_WARN_IF_MULTI_GL_VERSION_HEADERS_INCLUDED
#import <Cocoa/Cocoa.h>
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#include "OpenGLInclude.h"
#include <stdlib.h>
@@ -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];

View File

@@ -24,7 +24,7 @@ subject to the following restrictions:
//#include <OpenGL/gl.h>
//#include <OpenGL/glu.h>
//#import <Cocoa/Cocoa.h>
#ifdef USE_OPENGL2
#if defined (USE_OPENGL2) || defined (NO_OPENGL3)
#include <OpenGL/gl.h>
#else
#include <OpenGL/gl3.h>

View File

@@ -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

View File

@@ -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);