From 3c0e67298a7a52b9b7be68eccd72e4c2483ec6ad Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Fri, 7 Aug 2015 16:05:03 -0700 Subject: [PATCH] add command-line option --disable_retina for Mac improve TimeSeries and Dof6ConstaintTutorial --- .../ExampleBrowser/OpenGLExampleBrowser.cpp | 24 +++++++++----- examples/OpenGLWindow/MacOpenGLWindow.mm | 7 ++-- .../RenderingExamples/TimeSeriesCanvas.cpp | 3 +- .../RenderingExamples/TimeSeriesFontData.h | 2 +- examples/Tutorial/Dof6ConstraintTutorial.cpp | 1 + examples/Tutorial/Tutorial.cpp | 32 +++++++++++++++++-- 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp index 63dfc7ce5..b4c3f3c2f 100644 --- a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp +++ b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp @@ -52,13 +52,14 @@ static MyProfileWindow* s_profWindow =0; #define DEMO_SELECTION_COMBOBOX 13 const char* startFileName = "0_Bullet3Demo.txt"; - +char staticPngFileName[1024]; static GwenUserInterface* gui = 0; static int sCurrentDemoIndex = -1; static int sCurrentHightlighted = 0; static CommonExampleInterface* sCurrentDemo = 0; static b3AlignedObjectArray allNames; static float gFixedTimeStep = 0; +bool gAllowRetina = true; static class ExampleEntries* gAllExamples=0; bool sUseOpenGL2 = false; @@ -360,7 +361,10 @@ static void saveCurrentSettings(int currentEntry,const char* startFileName) fprintf(f,"--background_color_green= %f\n", green); fprintf(f,"--background_color_blue= %f\n", blue); fprintf(f,"--fixed_timestep= %f\n", gFixedTimeStep); - + if (!gAllowRetina) + { + fprintf(f,"--disable_retina"); + } if (enable_experimental_opencl) { @@ -678,7 +682,11 @@ bool OpenGLExampleBrowser::init(int argc, char* argv[]) enable_experimental_opencl = true; gAllExamples->initOpenCLExampleEntries(); } - + if (args.CheckCmdLineFlag("disable_retina")) + { + gAllowRetina = false; + } + int width = 1024; int height=768; @@ -978,11 +986,11 @@ void OpenGLExampleBrowser::update(float deltaTime) { skip=0; //printf("gPngFileName=%s\n",gPngFileName); - static int s_frameCount = 0; - char fileName[1024]; - sprintf(fileName,"%s%d.png",gPngFileName,s_frameCount++); - b3Printf("Made screenshot %s",fileName); - s_app->dumpNextFrameToPng(fileName); + static int s_frameCount = 100; + + sprintf(staticPngFileName,"%s%d.png",gPngFileName,s_frameCount++); + //b3Printf("Made screenshot %s",staticPngFileName); + s_app->dumpNextFrameToPng(staticPngFileName); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } } diff --git a/examples/OpenGLWindow/MacOpenGLWindow.mm b/examples/OpenGLWindow/MacOpenGLWindow.mm index 71c73571a..3bb3f2559 100644 --- a/examples/OpenGLWindow/MacOpenGLWindow.mm +++ b/examples/OpenGLWindow/MacOpenGLWindow.mm @@ -39,7 +39,7 @@ void dumpInfo(void) - +extern bool gAllowRetina; // -------------------- View ------------------------ @@ -398,7 +398,10 @@ void MacOpenGLWindow::createWindow(const b3gWindowConstructionInfo& ci) //support HighResolutionOSX for Retina Macbook if (ci.m_openglVersion>=3) { - [m_internalData->m_myview setWantsBestResolutionOpenGLSurface:YES]; + if (gAllowRetina) + { + [m_internalData->m_myview setWantsBestResolutionOpenGLSurface:YES]; + } } NSSize sz; sz.width = 1; diff --git a/examples/RenderingExamples/TimeSeriesCanvas.cpp b/examples/RenderingExamples/TimeSeriesCanvas.cpp index 972e83609..8edf431a1 100644 --- a/examples/RenderingExamples/TimeSeriesCanvas.cpp +++ b/examples/RenderingExamples/TimeSeriesCanvas.cpp @@ -3,6 +3,7 @@ #include "LinearMath/btAlignedObjectArray.h" #include "TimeSeriesFontData.h" #include "LinearMath/btVector3.h" +#include struct DataSource { @@ -341,4 +342,4 @@ void TimeSeriesCanvas::nextTick() { shift1PixelToLeft(); m_internalData->m_canvasInterface->refreshImageData(m_internalData->m_canvasIndex); -} \ No newline at end of file +} diff --git a/examples/RenderingExamples/TimeSeriesFontData.h b/examples/RenderingExamples/TimeSeriesFontData.h index a762f283c..bfe149ba4 100644 --- a/examples/RenderingExamples/TimeSeriesFontData.h +++ b/examples/RenderingExamples/TimeSeriesFontData.h @@ -1,6 +1,6 @@ #ifndef TIME_SERIES_FONT_DATA_H #define TIME_SERIES_FONT_DATA_H -unsigned char sTimeSeriesFontData[]; +extern unsigned char sTimeSeriesFontData[]; #endif//TIME_SERIES_FONT_DATA_H diff --git a/examples/Tutorial/Dof6ConstraintTutorial.cpp b/examples/Tutorial/Dof6ConstraintTutorial.cpp index 9b65a91a8..0865b16c7 100644 --- a/examples/Tutorial/Dof6ConstraintTutorial.cpp +++ b/examples/Tutorial/Dof6ConstraintTutorial.cpp @@ -135,6 +135,7 @@ void Dof6ConstraintTutorial::initPhysics() m_dynamicsWorld->setGravity(btVector3(0,0,0)); // Setup a big ground box + if (0) { btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(200.),btScalar(5.),btScalar(200.))); btTransform groundTransform; diff --git a/examples/Tutorial/Tutorial.cpp b/examples/Tutorial/Tutorial.cpp index 946139fa6..77b90ba40 100644 --- a/examples/Tutorial/Tutorial.cpp +++ b/examples/Tutorial/Tutorial.cpp @@ -7,7 +7,7 @@ #include "LinearMath/btTransform.h" #include "../CommonInterfaces/CommonGUIHelperInterface.h" - +#include "../RenderingExamples/TimeSeriesCanvas.h" #include "stb_image/stb_image.h" struct LWPose @@ -109,6 +109,9 @@ class Tutorial : public CommonExampleInterface int m_tutorialIndex; LWRightBody* m_body; + + TimeSeriesCanvas* m_timeSeriesCanvas; + public: @@ -118,6 +121,13 @@ public: { m_app->setUpAxis(2); + m_timeSeriesCanvas = new TimeSeriesCanvas(app->m_2dCanvasInterface,512,256,"Position and Velocity"); + m_timeSeriesCanvas ->setupTimeSeries(5,100, 0); + m_timeSeriesCanvas->addDataSource("X position (m)", 255,0,0); + m_timeSeriesCanvas->addDataSource("X velocity (m/s)", 0,0,255); + m_timeSeriesCanvas->addDataSource("dX/dt (m/s)", 0,0,0); + + switch (m_tutorialIndex) { @@ -173,6 +183,8 @@ public: } virtual ~Tutorial() { + delete m_timeSeriesCanvas; + m_timeSeriesCanvas = 0; m_app->m_renderer->enableBlend(false); } @@ -186,8 +198,22 @@ public: } virtual void stepSimulation(float deltaTime) { - //m_body->m_linearVelocity=btVector3(0,0.1,0); - m_body->m_angularVelocity =btVector3(0,0.1,0); + + m_body->m_linearVelocity=btVector3(1,0,0); + + + float time = m_timeSeriesCanvas->getCurrentTime(); + + float xPos = m_body->m_worldPose.m_worldPosition.x(); + + float xVel = m_body->m_linearVelocity.x(); + + m_timeSeriesCanvas->insertDataAtCurrentTime(xPos,0,true); + m_timeSeriesCanvas->insertDataAtCurrentTime(xVel,1,true); + + m_timeSeriesCanvas->nextTick(); + + m_body->integrateTransform(deltaTime); m_app->m_renderer->writeSingleInstanceTransformToCPU(m_body->m_worldPose.m_worldPosition, m_body->m_worldPose.m_worldOrientation, m_body->m_graphicsIndex);