| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | #include <osg/Timer> |
|---|
| 7 | #include <osg/GraphicsContext> |
|---|
| 8 | #include <osg/GraphicsThread> |
|---|
| 9 | |
|---|
| 10 | #include <osgUtil/UpdateVisitor> |
|---|
| 11 | #include <osgUtil/CullVisitor> |
|---|
| 12 | #include <osgUtil/SceneView> |
|---|
| 13 | #include <osgUtil/GLObjectsVisitor> |
|---|
| 14 | |
|---|
| 15 | #include <osgDB/ReadFile> |
|---|
| 16 | #include <osgDB/DynamicLibrary> |
|---|
| 17 | #include <osgDB/Registry> |
|---|
| 18 | |
|---|
| 19 | #include <osgViewer/View> |
|---|
| 20 | |
|---|
| 21 | #include <map> |
|---|
| 22 | #include <list> |
|---|
| 23 | #include <iostream> |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | #if !defined(_WIN32) |
|---|
| 27 | |
|---|
| 28 | #include <osgViewer/GraphicsWindowX11> |
|---|
| 29 | #include <osgViewer/Viewer> |
|---|
| 30 | |
|---|
| 31 | void renderCamera(osg::Camera* camera) |
|---|
| 32 | { |
|---|
| 33 | osg::GraphicsContext* gc = camera->getGraphicsContext(); |
|---|
| 34 | if (!gc) return; |
|---|
| 35 | |
|---|
| 36 | osgUtil::SceneView* sceneView = dynamic_cast<osgUtil::SceneView*>(camera->getRenderingCache(0)); |
|---|
| 37 | if (!sceneView) return; |
|---|
| 38 | |
|---|
| 39 | gc->makeCurrent(); |
|---|
| 40 | |
|---|
| 41 | sceneView->cull(); |
|---|
| 42 | sceneView->draw(); |
|---|
| 43 | |
|---|
| 44 | gc->swapBuffers(); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | void setUpFrameStamp(osg::Camera* camera, osg::FrameStamp* frameStamp, osg::Node* loadedModel) |
|---|
| 48 | { |
|---|
| 49 | osgUtil::SceneView* sceneView = dynamic_cast<osgUtil::SceneView*>(camera->getRenderingCache(0)); |
|---|
| 50 | if (!sceneView) return; |
|---|
| 51 | |
|---|
| 52 | sceneView->setFrameStamp(frameStamp); |
|---|
| 53 | |
|---|
| 54 | sceneView->setSceneData(loadedModel); |
|---|
| 55 | |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | int main( int argc, char **argv ) |
|---|
| 59 | { |
|---|
| 60 | if (argc<2) |
|---|
| 61 | { |
|---|
| 62 | std::cout << argv[0] <<": requires filename argument." << std::endl; |
|---|
| 63 | return 1; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(argv[1]); |
|---|
| 68 | if (!loadedModel) |
|---|
| 69 | { |
|---|
| 70 | std::cout << argv[0] <<": No data loaded." << std::endl; |
|---|
| 71 | return 1; |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | |
|---|
| 75 | const osg::BoundingSphere& bs = loadedModel->getBound(); |
|---|
| 76 | osg::Matrix viewMatrix; |
|---|
| 77 | viewMatrix.makeLookAt(bs.center()-osg::Vec3(0.0,2.0f*bs.radius(),0.0),bs.center(),osg::Vec3(0.0f,0.0f,1.0f)); |
|---|
| 78 | |
|---|
| 79 | osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer; |
|---|
| 80 | viewer->setUpViewAcrossAllScreens(); |
|---|
| 81 | viewer->realize(); |
|---|
| 82 | |
|---|
| 83 | viewer->getCamera()->setClearColor(osg::Vec4f(0.6f,0.6f,0.8f,1.0f)); |
|---|
| 84 | |
|---|
| 85 | osg::ref_ptr<osg::FrameStamp> frameStamp = new osg::FrameStamp; |
|---|
| 86 | |
|---|
| 87 | unsigned int frameNum = 0; |
|---|
| 88 | |
|---|
| 89 | osgUtil::UpdateVisitor updateVisitor; |
|---|
| 90 | updateVisitor.setFrameStamp(frameStamp.get()); |
|---|
| 91 | |
|---|
| 92 | setUpFrameStamp(viewer->getCamera(), frameStamp.get(), loadedModel.get()); |
|---|
| 93 | for(unsigned i=0; i<viewer->getNumSlaves(); ++i) |
|---|
| 94 | { |
|---|
| 95 | osg::View::Slave& slave = viewer->getSlave(i); |
|---|
| 96 | setUpFrameStamp(slave._camera.get(), frameStamp.get(), loadedModel.get()); |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | osg::Timer_t start_tick = osg::Timer::instance()->tick(); |
|---|
| 101 | osg::Timer_t previous_tick = start_tick; |
|---|
| 102 | |
|---|
| 103 | while(true) |
|---|
| 104 | { |
|---|
| 105 | osg::Timer_t current_tick = osg::Timer::instance()->tick(); |
|---|
| 106 | |
|---|
| 107 | frameStamp->setReferenceTime(osg::Timer::instance()->delta_s(start_tick,current_tick)); |
|---|
| 108 | frameStamp->setFrameNumber(frameNum++); |
|---|
| 109 | |
|---|
| 110 | |
|---|
| 111 | previous_tick = current_tick; |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | loadedModel->accept(updateVisitor); |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | viewer->getCamera()->setViewMatrix(viewMatrix); |
|---|
| 118 | |
|---|
| 119 | viewer->updateSlaves(); |
|---|
| 120 | |
|---|
| 121 | if (viewer->getCamera() && viewer->getCamera()->getGraphicsContext()) renderCamera(viewer->getCamera()); |
|---|
| 122 | |
|---|
| 123 | for(unsigned i=0; i<viewer->getNumSlaves(); ++i) |
|---|
| 124 | { |
|---|
| 125 | osg::View::Slave& slave = viewer->getSlave(i); |
|---|
| 126 | if (slave._camera.valid() && slave._camera->getGraphicsContext()) renderCamera(slave._camera.get()); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | } |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | #else |
|---|
| 134 | |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | |
|---|
| 144 | |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | |
|---|
| 151 | struct CompileOperation : public osg::GraphicsThread::Operation |
|---|
| 152 | { |
|---|
| 153 | CompileOperation(osg::Node* scene): |
|---|
| 154 | osg::GraphicsThread::Operation("Compile",false), |
|---|
| 155 | _scene(scene) |
|---|
| 156 | { |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | virtual void operator () (osg::GraphicsContext* context) |
|---|
| 160 | { |
|---|
| 161 | std::cout<<"Compile"<<std::endl; |
|---|
| 162 | |
|---|
| 163 | osgUtil::GLObjectsVisitor compileVisitor; |
|---|
| 164 | compileVisitor.setState(context->getState()); |
|---|
| 165 | |
|---|
| 166 | |
|---|
| 167 | _scene->accept(compileVisitor); |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | osg::ref_ptr<osg::Node> _scene; |
|---|
| 171 | }; |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | struct CullOperation : public osg::GraphicsThread::Operation |
|---|
| 175 | { |
|---|
| 176 | CullOperation(osgUtil::SceneView* sceneView): |
|---|
| 177 | osg::GraphicsThread::Operation("Cull",true), |
|---|
| 178 | _sceneView(sceneView) |
|---|
| 179 | { |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | virtual void operator () (osg::GraphicsContext* context) |
|---|
| 183 | { |
|---|
| 184 | _sceneView->setState(context->getState()); |
|---|
| 185 | _sceneView->cull(); |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | osg::ref_ptr<osgUtil::SceneView> _sceneView; |
|---|
| 189 | }; |
|---|
| 190 | |
|---|
| 191 | |
|---|
| 192 | struct DrawOperation : public osg::GraphicsThread::Operation |
|---|
| 193 | { |
|---|
| 194 | DrawOperation(osgUtil::SceneView* sceneView): |
|---|
| 195 | osg::GraphicsThread::Operation("Draw",true), |
|---|
| 196 | _sceneView(sceneView) |
|---|
| 197 | { |
|---|
| 198 | } |
|---|
| 199 | |
|---|
| 200 | virtual void operator () (osg::GraphicsContext*) |
|---|
| 201 | { |
|---|
| 202 | _sceneView->draw(); |
|---|
| 203 | } |
|---|
| 204 | |
|---|
| 205 | osg::ref_ptr<osgUtil::SceneView> _sceneView; |
|---|
| 206 | }; |
|---|
| 207 | |
|---|
| 208 | struct CleanUpOperation : public osg::GraphicsThread::Operation |
|---|
| 209 | { |
|---|
| 210 | CleanUpOperation(osgUtil::SceneView* sceneView): |
|---|
| 211 | osg::GraphicsThread::Operation("CleanUp",false), |
|---|
| 212 | _sceneView(sceneView) |
|---|
| 213 | { |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | virtual void operator () (osg::GraphicsContext*) |
|---|
| 217 | { |
|---|
| 218 | _sceneView->releaseAllGLObjects(); |
|---|
| 219 | _sceneView->flushAllDeletedGLObjects(); |
|---|
| 220 | } |
|---|
| 221 | |
|---|
| 222 | osg::ref_ptr<osgUtil::SceneView> _sceneView; |
|---|
| 223 | }; |
|---|
| 224 | |
|---|
| 225 | |
|---|
| 226 | |
|---|
| 227 | |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | |
|---|
| 234 | |
|---|
| 235 | |
|---|
| 236 | |
|---|
| 237 | |
|---|
| 238 | |
|---|
| 239 | |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | |
|---|
| 243 | |
|---|
| 244 | |
|---|
| 245 | |
|---|
| 246 | int main( int argc, char **argv ) |
|---|
| 247 | { |
|---|
| 248 | osg::Referenced::setThreadSafeReferenceCounting(true); |
|---|
| 249 | |
|---|
| 250 | |
|---|
| 251 | osg::ArgumentParser arguments(&argc,argv); |
|---|
| 252 | |
|---|
| 253 | std::string windowingLibrary("osgProducer"); |
|---|
| 254 | while (arguments.read("--windowing",windowingLibrary)) {} |
|---|
| 255 | |
|---|
| 256 | |
|---|
| 257 | osg::ref_ptr<osgDB::DynamicLibrary> windowingLib = |
|---|
| 258 | osgDB::DynamicLibrary::loadLibrary(osgDB::Registry::instance()->createLibraryNameForNodeKit(windowingLibrary)); |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | if (!windowingLib) |
|---|
| 262 | { |
|---|
| 263 | std::cout<<"Error: failed to loading windowing library: "<<windowingLibrary<<std::endl; |
|---|
| 264 | } |
|---|
| 265 | |
|---|
| 266 | osg::GraphicsContext::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface(); |
|---|
| 267 | if (!wsi) |
|---|
| 268 | { |
|---|
| 269 | std::cout<<"No WindowSystemInterface available, cannot create windows."<<std::endl; |
|---|
| 270 | return 1; |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | |
|---|
| 274 | osg::ref_ptr<osgViewer::View> view = new osgViewer::View; |
|---|
| 275 | view->setUpViewAcrossAllScreens(); |
|---|
| 276 | |
|---|
| 277 | |
|---|
| 278 | |
|---|
| 279 | |
|---|
| 280 | unsigned int numScreens = wsi->getNumScreens(); |
|---|
| 281 | |
|---|
| 282 | unsigned int numberCameras = numScreens; |
|---|
| 283 | while (arguments.read("--cameras",numberCameras)) {} |
|---|
| 284 | |
|---|
| 285 | unsigned int xpos = 0; |
|---|
| 286 | unsigned int ypos = 400; |
|---|
| 287 | unsigned int width = 400; |
|---|
| 288 | unsigned int height = 400; |
|---|
| 289 | |
|---|
| 290 | while (arguments.read("--xpos",xpos)) {} |
|---|
| 291 | while (arguments.read("--ypos",ypos)) {} |
|---|
| 292 | while (arguments.read("--height",height)) {} |
|---|
| 293 | while (arguments.read("--width",width)) {} |
|---|
| 294 | |
|---|
| 295 | unsigned int maxNumFrames = 1000; |
|---|
| 296 | while (arguments.read("--max-num-frames",maxNumFrames)) {} |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); |
|---|
| 300 | if (!loadedModel) |
|---|
| 301 | { |
|---|
| 302 | std::cout << argv[0] <<": No data loaded." << std::endl; |
|---|
| 303 | return 1; |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | osg::ref_ptr<osg::FrameStamp> frameStamp = new osg::FrameStamp; |
|---|
| 309 | |
|---|
| 310 | unsigned int frameNum = 0; |
|---|
| 311 | |
|---|
| 312 | osgUtil::UpdateVisitor updateVisitor; |
|---|
| 313 | updateVisitor.setFrameStamp(frameStamp.get()); |
|---|
| 314 | |
|---|
| 315 | typedef std::list< osg::ref_ptr<osg::Camera> > CameraList; |
|---|
| 316 | typedef std::set< osg::GraphicsContext* > GraphicsContextSet; |
|---|
| 317 | |
|---|
| 318 | CameraList cameraList; |
|---|
| 319 | GraphicsContextSet graphicsContextSet; |
|---|
| 320 | |
|---|
| 321 | |
|---|
| 322 | |
|---|
| 323 | |
|---|
| 324 | bool shareContexts = false; |
|---|
| 325 | osg::GraphicsContext* previousContext = 0; |
|---|
| 326 | for(unsigned int i=0; i< numberCameras; ++i) |
|---|
| 327 | { |
|---|
| 328 | osg::ref_ptr<osg::Camera> camera = new osg::Camera; |
|---|
| 329 | camera->addChild(loadedModel.get()); |
|---|
| 330 | |
|---|
| 331 | osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; |
|---|
| 332 | traits->_windowName = "osgcamera"; |
|---|
| 333 | traits->_screenNum = i % numScreens; |
|---|
| 334 | traits->_x = xpos; |
|---|
| 335 | traits->_y = ypos; |
|---|
| 336 | traits->_width = width; |
|---|
| 337 | traits->_height = height; |
|---|
| 338 | traits->_windowDecoration = true; |
|---|
| 339 | traits->_doubleBuffer = true; |
|---|
| 340 | traits->_sharedContext = shareContexts ? previousContext : 0; |
|---|
| 341 | |
|---|
| 342 | xpos += width; |
|---|
| 343 | |
|---|
| 344 | osg::ref_ptr<osg::GraphicsContext> gfxc = osg::GraphicsContext::createGraphicsContext(traits.get()); |
|---|
| 345 | |
|---|
| 346 | if (!gfxc) |
|---|
| 347 | { |
|---|
| 348 | std::cout<<"Unable to create window."<<std::endl; |
|---|
| 349 | return 1; |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | camera->setGraphicsContext(gfxc.get()); |
|---|
| 353 | |
|---|
| 354 | |
|---|
| 355 | const osg::BoundingSphere& bs = loadedModel->getBound(); |
|---|
| 356 | osg::Matrix viewMatrix; |
|---|
| 357 | viewMatrix.makeLookAt(bs.center()-osg::Vec3(0.0,2.0f*bs.radius(),0.0),bs.center(),osg::Vec3(0.0f,0.0f,1.0f)); |
|---|
| 358 | |
|---|
| 359 | camera->setViewport(0,0,traits->_width,traits->_height); |
|---|
| 360 | camera->setProjectionMatrixAsPerspective(50.0f,1.4f,1.0f,10000.0f); |
|---|
| 361 | camera->setViewMatrix(viewMatrix); |
|---|
| 362 | |
|---|
| 363 | |
|---|
| 364 | gfxc->createGraphicsThread(); |
|---|
| 365 | |
|---|
| 366 | cameraList.push_back(camera); |
|---|
| 367 | |
|---|
| 368 | previousContext = gfxc.get(); |
|---|
| 369 | } |
|---|
| 370 | |
|---|
| 371 | |
|---|
| 372 | |
|---|
| 373 | CameraList::iterator citr; |
|---|
| 374 | for(citr = cameraList.begin(); |
|---|
| 375 | citr != cameraList.end(); |
|---|
| 376 | ++citr) |
|---|
| 377 | { |
|---|
| 378 | graphicsContextSet.insert(const_cast<osg::GraphicsContext*>((*citr)->getGraphicsContext())); |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | |
|---|
| 382 | std::cout<<"Number of cameras = "<<cameraList.size()<<std::endl; |
|---|
| 383 | std::cout<<"Number of graphics contexts = "<<graphicsContextSet.size()<<std::endl; |
|---|
| 384 | |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | GraphicsContextSet::iterator gitr; |
|---|
| 388 | osg::ref_ptr<CompileOperation> compileOp = new CompileOperation(loadedModel.get()); |
|---|
| 389 | for(gitr = graphicsContextSet.begin(); |
|---|
| 390 | gitr != graphicsContextSet.end(); |
|---|
| 391 | ++gitr) |
|---|
| 392 | { |
|---|
| 393 | osg::GraphicsContext* context = *gitr; |
|---|
| 394 | context->getGraphicsThread()->add(compileOp.get(), false); |
|---|
| 395 | } |
|---|
| 396 | |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | osg::ref_ptr<osg::BarrierOperation> frameBeginBarrierOp = new osg::BarrierOperation(graphicsContextSet.size()+1, osg::BarrierOperation::NO_OPERATION); |
|---|
| 400 | for(gitr = graphicsContextSet.begin(); |
|---|
| 401 | gitr != graphicsContextSet.end(); |
|---|
| 402 | ++gitr) |
|---|
| 403 | { |
|---|
| 404 | osg::GraphicsContext* context = *gitr; |
|---|
| 405 | context->getGraphicsThread()->add(frameBeginBarrierOp.get(), false); |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | osg::ref_ptr<osg::BarrierOperation> glFinishBarrierOp = new osg::BarrierOperation(graphicsContextSet.size(), osg::BarrierOperation::GL_FINISH); |
|---|
| 409 | |
|---|
| 410 | |
|---|
| 411 | |
|---|
| 412 | |
|---|
| 413 | bool doFinishBeforeNewDraw = false; |
|---|
| 414 | bool doFinishAfterSwap = false; |
|---|
| 415 | |
|---|
| 416 | |
|---|
| 417 | for(citr = cameraList.begin(); |
|---|
| 418 | citr != cameraList.end(); |
|---|
| 419 | ++citr) |
|---|
| 420 | { |
|---|
| 421 | osg::Camera* camera = citr->get(); |
|---|
| 422 | osg::GraphicsThread* graphicsThread = camera->getGraphicsContext()->getGraphicsThread(); |
|---|
| 423 | |
|---|
| 424 | |
|---|
| 425 | osgUtil::SceneView* sceneView = new osgUtil::SceneView; |
|---|
| 426 | sceneView->setDefaults(); |
|---|
| 427 | sceneView->setFrameStamp(frameStamp.get()); |
|---|
| 428 | sceneView->setCamera(camera); |
|---|
| 429 | |
|---|
| 430 | |
|---|
| 431 | graphicsThread->add( new CullOperation(sceneView), false); |
|---|
| 432 | |
|---|
| 433 | |
|---|
| 434 | if (doFinishBeforeNewDraw) graphicsThread->add( glFinishBarrierOp.get(), false); |
|---|
| 435 | |
|---|
| 436 | |
|---|
| 437 | graphicsThread->add( new DrawOperation(sceneView), false); |
|---|
| 438 | } |
|---|
| 439 | |
|---|
| 440 | |
|---|
| 441 | |
|---|
| 442 | |
|---|
| 443 | |
|---|
| 444 | |
|---|
| 445 | osg::ref_ptr<osg::BarrierOperation> frameEndBarrierOp = new osg::BarrierOperation(graphicsContextSet.size()+1, osg::BarrierOperation::NO_OPERATION); |
|---|
| 446 | osg::ref_ptr<osg::BarrierOperation> preSwapBarrierOp = new osg::BarrierOperation(graphicsContextSet.size(), osg::BarrierOperation::GL_FLUSH); |
|---|
| 447 | osg::ref_ptr<osg::SwapBuffersOperation> swapOp = new osg::SwapBuffersOperation(); |
|---|
| 448 | for(gitr = graphicsContextSet.begin(); |
|---|
| 449 | gitr != graphicsContextSet.end(); |
|---|
| 450 | ++gitr) |
|---|
| 451 | { |
|---|
| 452 | osg::GraphicsContext* context = *gitr; |
|---|
| 453 | |
|---|
| 454 | context->getGraphicsThread()->add(frameEndBarrierOp.get(), false); |
|---|
| 455 | |
|---|
| 456 | context->getGraphicsThread()->add(swapOp.get(), false); |
|---|
| 457 | |
|---|
| 458 | |
|---|
| 459 | if (doFinishAfterSwap) context->getGraphicsThread()->add(glFinishBarrierOp.get(), false); |
|---|
| 460 | } |
|---|
| 461 | |
|---|
| 462 | |
|---|
| 463 | |
|---|
| 464 | osg::Timer_t start_tick = osg::Timer::instance()->tick(); |
|---|
| 465 | osg::Timer_t previous_tick = start_tick; |
|---|
| 466 | |
|---|
| 467 | bool done = false; |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | while( !done && frameNum<maxNumFrames) |
|---|
| 471 | { |
|---|
| 472 | |
|---|
| 473 | osg::Timer_t current_tick = osg::Timer::instance()->tick(); |
|---|
| 474 | |
|---|
| 475 | frameStamp->setReferenceTime(osg::Timer::instance()->delta_s(start_tick,current_tick)); |
|---|
| 476 | frameStamp->setFrameNumber(frameNum++); |
|---|
| 477 | |
|---|
| 478 | |
|---|
| 479 | previous_tick = current_tick; |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | |
|---|
| 483 | loadedModel->accept(updateVisitor); |
|---|
| 484 | |
|---|
| 485 | |
|---|
| 486 | frameBeginBarrierOp->block(); |
|---|
| 487 | |
|---|
| 488 | |
|---|
| 489 | frameEndBarrierOp->block(); |
|---|
| 490 | |
|---|
| 491 | |
|---|
| 492 | for(gitr = graphicsContextSet.begin(); |
|---|
| 493 | gitr != graphicsContextSet.end(); |
|---|
| 494 | ++gitr) |
|---|
| 495 | { |
|---|
| 496 | osg::GraphicsContext* context = *gitr; |
|---|
| 497 | if (!context->isRealized()) done = true; |
|---|
| 498 | } |
|---|
| 499 | |
|---|
| 500 | } |
|---|
| 501 | |
|---|
| 502 | |
|---|
| 503 | std::cout<<"Exiting application"<<std::endl; |
|---|
| 504 | |
|---|
| 505 | |
|---|
| 506 | for(gitr = graphicsContextSet.begin(); |
|---|
| 507 | gitr != graphicsContextSet.end(); |
|---|
| 508 | ++gitr) |
|---|
| 509 | { |
|---|
| 510 | osg::GraphicsContext* context = *gitr; |
|---|
| 511 | osg::GraphicsThread* thread = context->getGraphicsThread(); |
|---|
| 512 | if (thread) |
|---|
| 513 | { |
|---|
| 514 | thread->removeAllOperations(); |
|---|
| 515 | thread->setDone(true); |
|---|
| 516 | } |
|---|
| 517 | } |
|---|
| 518 | |
|---|
| 519 | std::cout<<"Removed all operations"<<std::endl; |
|---|
| 520 | |
|---|
| 521 | return 0; |
|---|
| 522 | } |
|---|
| 523 | |
|---|
| 524 | #endif |
|---|