示例#1
0
int main(int argc, char* argv[])
{
	b3CommandLineArgs args(argc,argv);
	b3Clock clock;
	
	
	ExampleEntriesAll examples;
	examples.initExampleEntries();

	ExampleBrowserInterface* exampleBrowser = new DefaultBrowser(&examples);
	bool init = exampleBrowser->init(argc,argv);
	clock.reset();
	if (init)
	{
		do 
		{
			float deltaTimeInSeconds = clock.getTimeMicroseconds()/1000000.f;
			clock.reset();
			exampleBrowser->update(deltaTimeInSeconds);

		} while (!exampleBrowser->requestedExit());
	}
	delete exampleBrowser;
	
	
	return 0;
}
示例#2
0
int main(int argc, char* argv[])
{

#ifndef _WIN32
    struct sigaction action;
    memset(&action, 0x0, sizeof(action));
    action.sa_handler = cleanup;
    static const int signos[] = { SIGHUP, SIGINT, SIGQUIT, SIGABRT, SIGSEGV, SIGPIPE, SIGTERM };
    for (int ii(0); ii < sizeof(signos) / sizeof(*signos); ++ii) {
        if (0 != sigaction(signos[ii], &action, NULL)) {
            err(EXIT_FAILURE, "signal %d", signos[ii]);
        }
    }
#endif

	{
		b3CommandLineArgs args(argc, argv);
		b3Clock clock;
		args.GetCmdLineArgument("minUpdateTimeMicroSecs",gMinUpdateTimeMicroSecs);

		ExampleEntriesAll examples;
		examples.initExampleEntries();

		OpenGLExampleBrowser* exampleBrowser = new OpenGLExampleBrowser(&examples);
		sExampleBrowser = exampleBrowser;//for <CTRL-C> etc, cleanup shared memory
		bool init = exampleBrowser->init(argc, argv);
		exampleBrowser->registerFileImporter(".urdf", ImportURDFCreateFunc);
		exampleBrowser->registerFileImporter(".sdf", ImportSDFCreateFunc);
		exampleBrowser->registerFileImporter(".obj", ImportObjCreateFunc);
		exampleBrowser->registerFileImporter(".stl", ImportSTLCreateFunc);
		exampleBrowser->registerFileImporter(".bullet", SerializeBulletCreateFunc);


		clock.reset();
		if (init)
		{
			do
			{
				float deltaTimeInSeconds = clock.getTimeMicroseconds() / 1000000.f;
				if (deltaTimeInSeconds > 0.1)
				{
					deltaTimeInSeconds = 0.1;
				}
				if (deltaTimeInSeconds < (gMinUpdateTimeMicroSecs/1e6))
				{
					b3Clock::usleep(gMinUpdateTimeMicroSecs/10.);
				} else
				{
					clock.reset();
					exampleBrowser->update(deltaTimeInSeconds);
				}
			} while (!exampleBrowser->requestedExit() && !interrupted);
		}
		delete exampleBrowser;

	}
	
#ifdef BT_DEBUG_MEMORY_ALLOCATIONS
	int numBytesLeaked = btDumpMemoryLeaks();
	btAssert(numBytesLeaked==0);
#endif//BT_DEBUG_MEMORY_ALLOCATIONS
	
	return 0;
}