#include <cstdlib>
#include <iostream>
#include <string>
+#include <unistd.h>
using namespace Dali;
using namespace Dali::Toolkit::Physics;
class Physics2dBenchmarkController : public ConnectionTracker
{
public:
- Physics2dBenchmarkController(Application& app, int numberOfBalls)
+ Physics2dBenchmarkController(Application& app, BenchmarkType startType, int numberOfBalls)
: mApplication(app),
+ mType(startType),
mBallNumber(numberOfBalls)
{
app.InitSignal().Connect(this, &Physics2dBenchmarkController::OnInit);
mWindow.GetRootLayer().TouchedSignal().Connect(this, &Physics2dBenchmarkController::OnTouched);
mWindow.SetBackgroundColor(Color::DARK_SLATE_GRAY);
- mType = BenchmarkType::ANIMATION;
-
CreateSimulation();
mTimer = Timer::New(ANIMATION_TIME);
void CreateAnimationSimulation()
{
+ DALI_LOG_RELEASE_INFO("Creating animation simulation with %d balls\n", mBallNumber);
+
Window::WindowSize windowSize = mWindow.GetSize();
mBallActors.resize(mBallNumber);
mBallVelocity.resize(mBallNumber);
void CreatePhysicsSimulation()
{
+ DALI_LOG_RELEASE_INFO("Creating physics simulation with %d balls\n", mBallNumber);
+
Window::WindowSize windowSize = mWindow.GetSize();
// Map Physics space (origin bottom left, +ve Y up)
{
setenv("DALI_FPS_TRACKING", "5", 1);
Application application = Application::New(&argc, &argv);
+ BenchmarkType startType = BenchmarkType::ANIMATION;
int numberOfBalls = DEFAULT_BALL_COUNT;
- if(argc > 1)
+ int opt=0;
+ optind=1;
+ while((opt=getopt(argc, argv, "ap")) != -1)
+ {
+ switch(opt)
+ {
+ case 'a':
+ startType = BenchmarkType::ANIMATION;
+ break;
+ case 'p':
+ startType = BenchmarkType::PHYSICS_2D;
+ break;
+ case 1:
+ // Should only trigger if optstring argument starts with "-", but check it anyway.
+ numberOfBalls = atoi(optarg);
+ break;
+ default:
+ fprintf(stderr, "Usage: %s [-p][-a] [n-balls]\n", argv[0]);
+ exit(1);
+ }
+ }
+ if(optind < argc)
{
- numberOfBalls = atoi(argv[1]);
+ numberOfBalls = atoi(argv[optind]);
}
- Physics2dBenchmarkController controller(application, numberOfBalls);
+ Physics2dBenchmarkController controller(application, startType, numberOfBalls);
application.MainLoop();
return 0;
}