| 47 | #endif //_WIN32 |
| 48 | |
| 49 | int main(int argc, char* argv[]) |
| 50 | { |
| 51 | #ifndef _WIN32 |
| 52 | struct sigaction action; |
| 53 | memset(&action, 0x0, sizeof(action)); |
| 54 | action.sa_handler = cleanup; |
| 55 | static const int signos[] = {SIGHUP, SIGINT, SIGQUIT, SIGABRT, SIGSEGV, SIGPIPE, SIGTERM}; |
| 56 | for (int ii(0); ii < sizeof(signos) / sizeof(*signos); ++ii) |
| 57 | { |
| 58 | if (0 != sigaction(signos[ii], &action, NULL)) |
| 59 | { |
| 60 | err(EXIT_FAILURE, "signal %d", signos[ii]); |
| 61 | } |
| 62 | } |
| 63 | #endif |
| 64 | |
| 65 | { |
| 66 | b3CommandLineArgs args(argc, argv); |
| 67 | b3Clock clock; |
| 68 | args.GetCmdLineArgument("minUpdateTimeMicroSecs", gMinUpdateTimeMicroSecs); |
| 69 | |
| 70 | ExampleEntriesAll examples; |
| 71 | examples.initExampleEntries(); |
| 72 | |
| 73 | OpenGLExampleBrowser* exampleBrowser = new OpenGLExampleBrowser(&examples); |
| 74 | sExampleBrowser = exampleBrowser; //for <CTRL-C> etc, cleanup shared memory |
| 75 | bool init = exampleBrowser->init(argc, argv); |
| 76 | exampleBrowser->registerFileImporter(".urdf", ImportURDFCreateFunc); |
| 77 | exampleBrowser->registerFileImporter(".sdf", ImportSDFCreateFunc); |
| 78 | exampleBrowser->registerFileImporter(".obj", ImportObjCreateFunc); |
| 79 | exampleBrowser->registerFileImporter(".stl", ImportSTLCreateFunc); |
| 80 | exampleBrowser->registerFileImporter(".bullet", SerializeBulletCreateFunc); |
| 81 | |
| 82 | clock.reset(); |
| 83 | if (init) |
| 84 | { |
| 85 | do |
| 86 | { |
| 87 | float deltaTimeInSeconds = clock.getTimeMicroseconds() / 1000000.f; |
| 88 | if (deltaTimeInSeconds > 0.1) |
| 89 | { |
| 90 | deltaTimeInSeconds = 0.1; |
| 91 | } |
| 92 | if (deltaTimeInSeconds < (gMinUpdateTimeMicroSecs / 1e6)) |
| 93 | { |
| 94 | b3Clock::usleep(gMinUpdateTimeMicroSecs / 10.); |
| 95 | } |
| 96 | else |
| 97 | { |
| 98 | clock.reset(); |
| 99 | exampleBrowser->update(deltaTimeInSeconds); |
| 100 | } |
| 101 | } while (!exampleBrowser->requestedExit() && !interrupted); |
| 102 | } |
| 103 | delete exampleBrowser; |
| 104 | } |
| 105 | |
| 106 | #ifdef BT_DEBUG_MEMORY_ALLOCATIONS |
nothing calls this directly
no test coverage detected