| 1090 | | viewer.getEventHandlerList().push_front(new TechniqueEventHandler(ttm.get())); |
| 1091 | | |
| 1092 | | // get details on keyboard and mouse bindings used by the viewer. |
| 1093 | | viewer.getUsage(*arguments.getApplicationUsage()); |
| 1094 | | |
| 1095 | | // if user request help write it out to cout. |
| 1096 | | if (arguments.read("-h") || arguments.read("--help")) |
| 1097 | | { |
| 1098 | | arguments.getApplicationUsage()->write(std::cout); |
| 1099 | | return 1; |
| 1100 | | } |
| 1101 | | |
| 1102 | | // any option left unread are converted into errors to write out later. |
| 1103 | | arguments.reportRemainingOptionsAsUnrecognized(); |
| 1104 | | |
| 1105 | | // report any errors if they have occured when parsing the program aguments. |
| 1106 | | if (arguments.errors()) |
| 1107 | | { |
| 1108 | | arguments.writeErrorMessages(std::cout); |
| 1109 | | return 1; |
| 1110 | | } |
| 1111 | | |
| 1112 | | osg::Node* node = ttm->createScene((unsigned int)numTreesToCreates); |
| | 1083 | viewer.addEventHandler(new TechniqueEventHandler(ttm.get())); |
| 1115 | | viewer.setSceneData( node ); |
| 1116 | | |
| 1117 | | // create the windows and run the threads. |
| 1118 | | viewer.realize(); |
| 1119 | | |
| 1120 | | while( !viewer.done() ) |
| 1121 | | { |
| 1122 | | // wait for all cull and draw threads to complete. |
| 1123 | | viewer.sync(); |
| 1124 | | |
| 1125 | | // update the scene by traversing it with the the update visitor which will |
| 1126 | | // call all node update callbacks and animations. |
| 1127 | | viewer.update(); |
| 1128 | | |
| 1129 | | // fire off the cull and draw traversals of the scene. |
| 1130 | | viewer.frame(); |
| 1131 | | |
| 1132 | | } |
| 1133 | | |
| 1134 | | // wait for all cull and draw threads to complete. |
| 1135 | | viewer.sync(); |
| 1136 | | |
| 1137 | | // run a clean up frame to delete all OpenGL objects. |
| 1138 | | viewer.cleanup_frame(); |
| 1139 | | |
| 1140 | | // wait for all the clean up frame to complete. |
| 1141 | | viewer.sync(); |
| 1142 | | |
| 1143 | | return 0; |
| 1144 | | } |
| | 1086 | viewer.setSceneData( ttm->createScene((unsigned int)numTreesToCreates) ); |
| | 1087 | |
| | 1088 | |
| | 1089 | return viewer.run(); |
| | 1090 | } |