add command-line option --disable_retina for Mac

improve TimeSeries and Dof6ConstaintTutorial
This commit is contained in:
Erwin Coumans
2015-08-07 16:05:03 -07:00
parent de4dcdbb18
commit 3c0e67298a
6 changed files with 54 additions and 15 deletions

View File

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

View File

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

View File

@@ -3,6 +3,7 @@
#include "LinearMath/btAlignedObjectArray.h"
#include "TimeSeriesFontData.h"
#include "LinearMath/btVector3.h"
#include <stdio.h>
struct DataSource
{
@@ -341,4 +342,4 @@ void TimeSeriesCanvas::nextTick()
{
shift1PixelToLeft();
m_internalData->m_canvasInterface->refreshImageData(m_internalData->m_canvasIndex);
}
}

View File

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

View File

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

View File

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