Changeset 20218
- Timestamp:
- 05/14/07 16:04:24 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/branches/2.0/modules/vrjuggler/vrj/Draw/Pf/PfDrawManager.cpp
r19941 r20218 80 80 81 81 // Draw Callbacks 82 void PfDrawFuncStereoLeft(pfChannel *chan, void* chandata);83 void PfDrawFuncStereoRight(pfChannel *chan, void* chandata);84 void PfDrawFuncMonoBackbuffer(pfChannel *chan, void* chandata);82 void PfDrawFuncStereoLeft(pfChannel* chan, void* chandata); 83 void PfDrawFuncStereoRight(pfChannel* chan, void* chandata); 84 void PfDrawFuncMonoBackbuffer(pfChannel* chan, void* chandata); 85 85 //void PfDrawFuncSimulator(pfChannel* chan, void* chandata); 86 //void PfAppFunc(pfChannel *chan, void* chandata);87 88 89 void PfPipeSwapFunc(pfPipe *p, pfPipeWindow *pw);86 //void PfAppFunc(pfChannel* chan, void* chandata); 87 88 89 void PfPipeSwapFunc(pfPipe* p, pfPipeWindow* pw); 90 90 91 91 vprSingletonImp(PfDrawManager); … … 94 94 { 95 95 //TODO: Add thread safety. 96 for ( std::vector<PfInputHandler*>::iterator itr = mPfInputHandlers.begin();97 itr != mPfInputHandlers.end() ; itr++)96 typedef std::vector<PfInputHandler*>::iterator iter_type; 97 for ( iter_type itr = mPfInputHandlers.begin(); itr != mPfInputHandlers.end(); ++itr ) 98 98 { 99 99 delete *itr; … … 123 123 // pipes when creating a new display_system element is 0. It needs to be this 124 124 // because we can not fill in the list of pipes with default values. 125 if (mNumPipes < 1)125 if ( mNumPipes < 1 ) 126 126 { 127 127 mNumPipes = 1; 128 128 } 129 129 130 for ( unsigned int i=0;i<mNumPipes;i++)130 for ( unsigned int i = 0; i < mNumPipes; ++i ) 131 131 { 132 132 std::string cur_disp_name = "-1"; 133 133 134 // NOTE: ConfigElements return the default value for a property if a value is135 // not present. So if a pipe string is not specified for this pipe then136 // it gets the default value of "-1".134 // NOTE: ConfigElements return the default value for a property if a 135 // value is not present. So if a pipe string is not specified for 136 // this pipe then it gets the default value of "-1". 137 137 mPipeStrs.push_back(element->getProperty<std::string>("x11_pipes", i)); 138 138 139 if (mPipeStrs[i] == cur_disp_name) // Use display env139 if ( mPipeStrs[i] == cur_disp_name ) // Use display env 140 140 { 141 141 std::string display_env; … … 152 152 << vprDEBUG_FLUSH; 153 153 } 154 154 155 return true; 155 156 } … … 179 180 pfFrame(); 180 181 181 for (std::vector<PfInputHandler*>::iterator itr = mPfInputHandlers.begin();182 itr != mPfInputHandlers.end() ; itr++)182 typedef std::vector<PfInputHandler*>::iterator iter_type; 183 for ( iter_type itr = mPfInputHandlers.begin(); itr != mPfInputHandlers.end(); ++itr ) 183 184 { 184 185 (*itr)->checkEvents(); 185 186 } 186 187 } 187 188 188 189 189 // XXX: Hack for now … … 193 193 // for(each viewport) 194 194 // for(each channel) 195 for (unsigned int dispIndex=0;dispIndex<mDisplays.size();dispIndex++)196 { 197 for (unsigned vp=0;vp<mDisplays[dispIndex].viewports.size();vp++)198 { 199 for (unsigned ch=0;ch<2;ch++)195 for ( unsigned int dispIndex = 0; dispIndex < mDisplays.size(); ++dispIndex ) 196 { 197 for ( unsigned int vp = 0; vp < mDisplays[dispIndex].viewports.size(); ++vp ) 198 { 199 for ( unsigned int ch = 0; ch < 2; ++ch ) 200 200 { 201 if(mDisplays[dispIndex].viewports[vp].chans[ch] != NULL) 201 if ( mDisplays[dispIndex].viewports[vp].chans[ch] != NULL ) 202 { 202 203 mApp->appChanFunc(mDisplays[dispIndex].viewports[vp].chans[ch]); 204 } 203 205 } 204 206 } 205 207 } 206 208 } 207 208 209 209 210 /** … … 212 213 * @post dynamic_cast<> of the app to a Pf app. 213 214 */ 214 void PfDrawManager::setApp(App* _app)215 void PfDrawManager::setApp(App* app) 215 216 { 216 217 //vprASSERT(app != NULL); 217 mApp = dynamic_cast<PfApp*>(_app); 218 if(mPfHasForked) 219 initAppGraph(); // If pf is already started, then intialize the app scene graph 220 218 mApp = dynamic_cast<PfApp*>(app); 219 220 // If pf is already started, then intialize the app scene graph. 221 if ( mPfHasForked ) 222 { 223 initAppGraph(); 224 } 221 225 } 222 226 … … 232 236 pfuInitUtil(); 233 237 234 // XXX: This call should really be triggered by a change in draw manager or something 238 // XXX: This call should really be triggered by a change in draw manager or 239 // something. 235 240 vprASSERT(mDisplayManager != NULL); 236 configDisplaySystem(mDisplayManager->getDisplaySystemElement()); // Configure all the display system stuff 241 242 // Configure all the display system stuff. 243 configDisplaySystem(mDisplayManager->getDisplaySystemElement()); 237 244 238 245 mApp->preForkInit(); … … 252 259 #else 253 260 // If we are running in a cluster then we must run in single process mode. 254 if (jccl::ConfigManager::instance()->isElementTypeInPendingList("cluster_manager") ||255 jccl::ConfigManager::instance()->isElementTypeInActiveList("cluster_manager"))261 if ( jccl::ConfigManager::instance()->isElementTypeInPendingList("cluster_manager") || 262 jccl::ConfigManager::instance()->isElementTypeInActiveList("cluster_manager") ) 256 263 { 257 264 vprDEBUG_BEGIN(vrjDBG_DRAW_MGR, vprDBG_STATE_LVL) … … 269 276 #endif 270 277 271 // We can not init head and wand model loaders since they are loaded in PfBasicSimInterface 278 // We can not init head and wand model loaders since they are loaded in 279 // PfBasicSimInterface. 272 280 // initLoaders(); // Must call before pfConfig 273 281 … … 281 289 282 290 // Initialize the pipes that the system may need 283 // If we don't do this, then pf automatically give each pipe a big black channel 291 // If we don't do this, then pf automatically give each pipe a big black 292 // channel. 284 293 initPipes(); 285 294 286 295 initPerformerGraph(); // Create the other scene graph nodes 287 if(mApp != NULL) 296 if ( NULL != mApp ) 297 { 288 298 initAppGraph(); // App was already set, but pf was not loaded. So load graph now 289 299 } 290 300 291 301 vprASSERT(mRoot != NULL && "We have a NULL root in PfDrawManager"); 292 vprASSERT(mRootWithSim != NULL && "We have a NULL sim root scene in PfDrawManager"); 293 vprASSERT(mSceneRoot != NULL && "We have a NULL root scene in PfDrawManager"); 302 vprASSERT(mRootWithSim != NULL && 303 "We have a NULL sim root scene in PfDrawManager"); 304 vprASSERT(mSceneRoot != NULL && 305 "We have a NULL root scene in PfDrawManager"); 294 306 295 307 //pfFrame(); … … 306 318 * Gets a Performer pipe. 307 319 * 308 * @pre pipe _num < mNumPipes320 * @pre pipeNum < mNumPipes 309 321 * Fork must have happened. 310 322 */ 311 pfPipe* PfDrawManager::getPfPipe(unsigned pipe_num)323 pfPipe* PfDrawManager::getPfPipe(unsigned int pipeNum) 312 324 { 313 325 vprASSERT((mPfHasForked) && "Tried to get pipe before forking happened"); 314 vprASSERT((pipe _num < mNumPipes) && "Tried to request out of bounds pipe");315 vprASSERT((pipe _num < mPipes.size()) && "Tried to get out of range pipe");316 vprASSERT((NULL != mPipes[pipe _num]) && "Have NULL pipe");326 vprASSERT((pipeNum < mNumPipes) && "Tried to request out of bounds pipe"); 327 vprASSERT((pipeNum < mPipes.size()) && "Tried to get out of range pipe"); 328 vprASSERT((NULL != mPipes[pipeNum]) && "Have NULL pipe"); 317 329 318 330 // Print an error message if an invalid pipe was requested. This will 319 331 // probably only happen when a configuration is broken. 320 if ( pipe _num >= mNumPipes || pipe_num >= mPipes.size() ||321 NULL == mPipes[pipe _num] )332 if ( pipeNum >= mNumPipes || pipeNum >= mPipes.size() || 333 NULL == mPipes[pipeNum] ) 322 334 { 323 335 vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL) 324 336 << clrOutNORM(clrRED, "ERROR") 325 << ": Invalid pipe number (" << pipe _num << ") requested. "337 << ": Invalid pipe number (" << pipeNum << ") requested. " 326 338 << "Check display system configuration.\n" << vprDEBUG_FLUSH; 327 339 return NULL; … … 330 342 { 331 343 // Return the actual pipe 332 return mPipes[pipe _num];344 return mPipes[pipeNum]; 333 345 } 334 346 } … … 341 353 mPipes.resize(mNumPipes, NULL); // Resize the vector 342 354 343 for (unsigned pipe_num=0; pipe_num<mNumPipes; pipe_num++)355 for ( unsigned int pipe_num = 0; pipe_num < mNumPipes; ++pipe_num ) 344 356 { 345 357 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL) … … 355 367 356 368 pfPipeWindow* pw = allocatePipeWin(pipe_num); // new pfPipeWindow(mPipes[pipe_num]); 357 pw->setOriginSize(0, 0,1,1);369 pw->setOriginSize(0, 0, 1, 1); 358 370 359 371 // XXX: Set the swap func 360 mPipes[pipe_num]->setSwapFunc( PfPipeSwapFunc );// Set to the given swap func372 mPipes[pipe_num]->setSwapFunc(PfPipeSwapFunc); // Set to the given swap func 361 373 } 362 374 } … … 371 383 { 372 384 vprASSERT(disp != NULL); // Can't add a null display 373 vprASSERT((true == mPfHasForked) && "Trying to add display when performer has not been initialized"); 385 vprASSERT(mPfHasForked && 386 "Trying to add display when performer has not been initialized"); 374 387 375 388 // For the display … … 414 427 // Setup window border 415 428 if (disp->shouldDrawBorder()) 429 { 416 430 pf_disp.pWin->setName(disp->getName().c_str()); // Give the window a name 431 } 417 432 else 418 pf_disp.pWin->setMode(PFWIN_NOBORDER, 1); // Get rid of that border 433 { 434 pf_disp.pWin->setMode(PFWIN_NOBORDER, 1); // Get rid of that border 435 } 419 436 420 437 jccl::ConfigElementPtr fb_elt = disp->getGlFrameBufferConfig(); … … 490 507 // - Setup master chans 491 508 Viewport* viewport = NULL; 492 unsignednum_vps = disp->getNumViewports();509 const unsigned int num_vps = disp->getNumViewports(); 493 510 494 511 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL) 495 512 << " Num viewports: " << num_vps << std::endl << vprDEBUG_FLUSH; 496 513 497 for (unsigned vp_num=0; vp_num < num_vps; vp_num++)514 for ( unsigned int vp_num = 0; vp_num < num_vps; ++vp_num ) 498 515 { 499 516 viewport = disp->getViewport(vp_num); 500 517 501 if (viewport->isActive()) // is viewport active518 if ( viewport->isActive() ) // is viewport active 502 519 { 503 520 //Viewport::View view = viewport->getView(); 504 pfViewport pf_viewport; // The viewport to build up521 pfViewport pf_viewport; // The viewport to build up 505 522 pf_viewport.viewport = viewport; 506 523 float vp_ox, vp_oy, vp_sx, vp_sy; … … 510 527 viewport->getOriginAndSize(vp_ox, vp_oy, vp_sx, vp_sy); 511 528 pf_viewport.chans[pfViewport::PRIMARY] = new pfChannel(pipe); 512 pf_viewport.chans[pfViewport::PRIMARY]->setViewport(vp_ox, vp_ox+vp_sx, vp_oy, vp_oy+vp_sy); 529 pf_viewport.chans[pfViewport::PRIMARY]->setViewport(vp_ox, 530 vp_ox + vp_sx, 531 vp_oy, 532 vp_oy + vp_sy); 513 533 pf_disp.pWin->addChan(pf_viewport.chans[pfViewport::PRIMARY]); 514 534 515 535 // Secondary channel - (Right in stereo) 516 if (disp->isStereoRequested())536 if ( disp->isStereoRequested() ) 517 537 { 518 538 pf_viewport.chans[pfViewport::SECONDARY] = new pfChannel(pipe); 519 pf_viewport.chans[pfViewport::SECONDARY]->setViewport(vp_ox, vp_ox+vp_sx, vp_oy, vp_oy+vp_sy); 539 pf_viewport.chans[pfViewport::SECONDARY]->setViewport(vp_ox, 540 vp_ox + vp_sx, 541 vp_oy, 542 vp_oy + vp_sy); 520 543 pf_disp.pWin->addChan(pf_viewport.chans[pfViewport::SECONDARY]); 521 544 } 522 545 523 546 // Set draw function 524 if (disp->isStereoRequested())547 if ( disp->isStereoRequested() ) 525 548 { 526 pf_viewport.chans[pfViewport::PRIMARY]->setTravFunc(PFTRAV_DRAW, PfDrawFuncStereoLeft); 527 pf_viewport.chans[pfViewport::SECONDARY]->setTravFunc(PFTRAV_DRAW, PfDrawFuncStereoRight); 549 pf_viewport.chans[pfViewport::PRIMARY]->setTravFunc(PFTRAV_DRAW, 550 PfDrawFuncStereoLeft); 551 pf_viewport.chans[pfViewport::SECONDARY]->setTravFunc(PFTRAV_DRAW, 552 PfDrawFuncStereoRight); 528 553 } 529 554 else 530 555 { 531 pf_viewport.chans[pfViewport::PRIMARY]->setTravFunc(PFTRAV_DRAW, PfDrawFuncMonoBackbuffer); 556 pf_viewport.chans[pfViewport::PRIMARY]->setTravFunc(PFTRAV_DRAW, 557 PfDrawFuncMonoBackbuffer); 532 558 } 533 559 534 560 // if surface ==> Setup surface channels 535 if ( viewport->isSurface())561 if ( viewport->isSurface() ) 536 562 { 537 563 vprASSERT(pf_viewport.chans[pfViewport::PRIMARY] != NULL); 538 564 539 565 // Primary 540 if (NULL == mSurfMasterChan) // If NULL, then add us as the new one566 if ( NULL == mSurfMasterChan ) // If NULL, then add us as the new one 541 567 { 542 568 mSurfMasterChan = pf_viewport.chans[pfViewport::PRIMARY]; … … 552 578 553 579 // Secondary 554 if (NULL != pf_viewport.chans[pfViewport::SECONDARY])580 if ( NULL != pf_viewport.chans[pfViewport::SECONDARY] ) 555 581 { 556 582 mSurfChannels.push_back(pf_viewport.chans[pfViewport::SECONDARY]); 557 583 mSurfMasterChan->attach(pf_viewport.chans[pfViewport::SECONDARY]); 558 584 } 559 560 585 } 561 586 // if sim ==> setup sim channels 562 else if (viewport->isSimulator())587 else if ( viewport->isSimulator() ) 563 588 { 564 589 // -- Finish Simulator setup … … 572 597 573 598 // Create the simulator stuff 574 vprASSERT(1 == vp_element->getNum("simulator_plugin") && "You must supply a simulator plugin."); 599 vprASSERT(1 == vp_element->getNum("simulator_plugin") && 600 "You must supply a simulator plugin."); 575 601 576 602 jccl::ConfigElementPtr sim_element = … … 595 621 596 622 // Primary 597 if (NULL == mSimMasterChan) // If NULL, then make us the master623 if ( NULL == mSimMasterChan ) // If NULL, then make us the master 598 624 { 599 625 mSimMasterChan = pf_viewport.chans[pfViewport::PRIMARY]; … … 609 635 610 636 // Secondary 611 if (NULL != pf_viewport.chans[pfViewport::SECONDARY])637 if ( NULL != pf_viewport.chans[pfViewport::SECONDARY] ) 612 638 { 613 639 mSimChannels.push_back(pf_viewport.chans[pfViewport::SECONDARY]); … … 618 644 // Add viewport to the display list 619 645 pf_disp.viewports.push_back(pf_viewport); 620 621 646 } // is viewport active 622 647 } // for each viewport … … 634 659 // Performer says that if you trigger a window from the applciation proccess 635 660 // you must wait for the window to open during the draw process. 636 while ( !pfIsPWinOpen( pf_disp.pWin) )661 while ( ! pfIsPWinOpen(pf_disp.pWin) ) 637 662 { 638 663 pfFrame(); 639 vpr::System::usleep( 500 ); 640 } 641 642 PfInputHandler* new_input_handler = new PfInputHandler(pf_disp.pWin, disp->getName()); 664 vpr::System::usleep(500); 665 } 666 667 PfInputHandler* new_input_handler = 668 new PfInputHandler(pf_disp.pWin, disp->getName()); 643 669 644 670 // Configure the Performer window to accept events. … … 646 672 new_input_handler->config(display_elt, disp); 647 673 648 649 674 mPfInputHandlers.push_back(new_input_handler); 650 675 651 if (pf_disp.disp->shouldHideMouse())676 if ( pf_disp.disp->shouldHideMouse() ) 652 677 { 653 678 pfuLoadPWinCursor(pf_disp.pWin, PFU_CURSOR_OFF); … … 685 710 */ 686 711 687 688 689 690 712 /** 691 713 * Callback when display is removed to display manager. … … 709 731 } 710 732 #else 711 std::vector<pfDisplay>::iterator disp_i = std::find_if(mDisplays.begin(), mDisplays.end(), 712 std::compose1( std::bind2nd( std::equal_to<Display*>(),disp), 713 pfDisplay_disp()) ); 733 std::vector<pfDisplay>::iterator disp_i = 734 std::find_if(mDisplays.begin(), mDisplays.end(), 735 std::compose1(std::bind2nd(std::equal_to<Display*>(), disp), 736 pfDisplay_disp())); 714 737 #endif 715 738 716 717 if(mDisplays.end() == disp_i) 739 if ( mDisplays.end() == disp_i ) 718 740 { 719 741 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) … … 723 745 } 724 746 725 726 747 // Release the pfDisplay 727 748 releaseDisplay(*disp_i); … … 734 755 { 735 756 // Release all viewports 736 for(std::vector<pfViewport>::iterator i=disp.viewports.begin(); i != disp.viewports.end(); i++) 757 typedef std::vector<pfViewport>::iterator iter_type; 758 for ( iter_type i = disp.viewports.begin(); i != disp.viewports.end(); ++i ) 737 759 { 738 760 releaseViewport(disp, *i); … … 743 765 } 744 766 745 746 767 void PfDrawManager::releaseViewport(pfDisplay& disp, pfViewport& vp) 747 768 { … … 749 770 750 771 // Release the channel stuff 751 for (int i=0;i<2;i++)772 for ( int i = 0; i < 2; ++i ) 752 773 { 753 774 pfChannel* chan = vp.chans[i]; 754 775 755 776 // if we have a channel to delete 756 if (chan != NULL)757 { 758 if (vp.viewport->isSurface()) // SURFACE display777 if ( chan != NULL ) 778 { 779 if ( vp.viewport->isSurface() ) // SURFACE display 759 780 { 760 781 // Remove the channel from the list of channels 761 chan_i = std::find(mSurfChannels.begin(), mSurfChannels.end(), chan); 762 if(chan_i == mSurfChannels.end()) 782 chan_i = std::find(mSurfChannels.begin(), mSurfChannels.end(), 783 chan); 784 785 if ( chan_i == mSurfChannels.end() ) 763 786 { 764 787 vprASSERT(false && "Trying to remove a non-existant channel"); … … 769 792 770 793 // Check if we were the master 771 if (chan == mSurfMasterChan)794 if ( chan == mSurfMasterChan ) 772 795 { 773 mSurfMasterChan = NULL; // Get new master channel 774 if(mSurfChannels.size() > 0) 796 mSurfMasterChan = NULL; // Get new master channel 797 if ( mSurfChannels.size() > 0 ) 798 { 775 799 mSurfMasterChan = mSurfChannels[0]; 800 } 776 801 } 777 802 778 if(mSurfMasterChan != NULL) // Dettach from the channel 803 if ( mSurfMasterChan != NULL ) // Dettach from the channel 804 { 779 805 chan->detach(mSurfMasterChan); 806 } 780 807 } 781 else if (vp.viewport->isSimulator()) // SIMULATOR display808 else if ( vp.viewport->isSimulator() ) // SIMULATOR display 782 809 { 783 810 // Remove the channel from the list of channels 784 811 chan_i = std::find(mSimChannels.begin(), mSimChannels.end(), chan); 785 if (chan_i == mSimChannels.end())812 if ( chan_i == mSimChannels.end() ) 786 813 { 787 814 vprASSERT(false && "Trying to remove a non-existant channel"); … … 792 819 793 820 // Check if we were the master 794 if (chan == mSimMasterChan)821 if ( chan == mSimMasterChan ) 795 822 { 796 mSimMasterChan = NULL; // Get new master channel 797 if(mSimChannels.size() > 0) 823 mSimMasterChan = NULL; // Get new master channel 824 if ( mSimChannels.size() > 0 ) 825 { 798 826 mSimMasterChan = mSimChannels[0]; 827 } 799 828 } 800 829 801 if(mSimMasterChan != NULL) // Dettach from the channel 830 if ( mSimMasterChan != NULL ) // Dettach from the channel 831 { 802 832 chan->detach(mSimMasterChan); 833 } 803 834 } 804 835 805 836 chan->setScene(NULL); 806 837 disp.pWin->removeChan(chan); // Remove channel from pwin 807 pfDelete( chan); // Delete the channel 808 } 809 } 810 } 811 812 838 pfDelete(chan); // Delete the channel 839 } 840 } 841 } 813 842 814 843 // Get a pipe window to use 815 // This either allocates a new pipe window or grabs an unused one that was previously released 816 pfPipeWindow* PfDrawManager::allocatePipeWin(unsigned pipeNum) 844 // This either allocates a new pipe window or grabs an unused one that was 845 // previously released 846 pfPipeWindow* PfDrawManager::allocatePipeWin(const unsigned int pipeNum) 817 847 { 818 848 pfPipeWindow* ret_val; … … 824 854 } 825 855 826 if (mPipeWindows[pipeNum].size() > 0) // Is one available856 if ( mPipeWindows[pipeNum].size() > 0 ) // Is one available 827 857 { 828 858 ret_val = mPipeWindows[pipeNum].back(); … … 831 861 else 832 862 { 833 ret_val = new pfPipeWindow(getPfPipe(pipeNum)); // Allocate a new one863 ret_val = new pfPipeWindow(getPfPipe(pipeNum)); // Allocate a new one 834 864 } 835 865 … … 840 870 841 871 // Just store the old pipe window in the list 842 void PfDrawManager::releasePipeWin(pfPipeWindow* pipeWin, unsigned pipeNum) 872 void PfDrawManager::releasePipeWin(pfPipeWindow* pipeWin, 873 const unsigned int pipeNum) 843 874 { 844 875 mPipeWindows[pipeNum].push_back(pipeWin); 845 876 } 846 847 848 877 849 878 // Initialize the parameters of the master channel … … 864 893 // Set the Channel attribs based on cur settings 865 894 // 866 unsigned cur_share = masterChan->getShare(); // Get current setting, and OR the new stuff on 867 unsigned turn_on = ( PFCHAN_NEARFAR | PFCHAN_EARTHSKY | 868 PFCHAN_STRESS | PFCHAN_LOD | PFCHAN_SWAPBUFFERS | 869 PFCHAN_APPFUNC | PFCHAN_SCENE | PFCHAN_CULLFUNC | 870 PFCHAN_STATS_DRAWMODE); 871 unsigned turn_off = ( PFCHAN_FOV | 872 PFCHAN_VIEW | 873 PFCHAN_VIEW_OFFSETS | 874 PFCHAN_DRAWFUNC ); 875 876 masterChan->setShare((cur_share | turn_on) &(~turn_off)); 895 const unsigned int cur_share = masterChan->getShare(); // Get current setting, and OR the new stuff on 896 const unsigned int turn_on = PFCHAN_NEARFAR | PFCHAN_EARTHSKY | 897 PFCHAN_STRESS | PFCHAN_LOD | 898 PFCHAN_SWAPBUFFERS | PFCHAN_APPFUNC | 899 PFCHAN_SCENE | PFCHAN_CULLFUNC | 900 PFCHAN_STATS_DRAWMODE; 901 const unsigned int turn_off = PFCHAN_FOV | 902 PFCHAN_VIEW | 903 PFCHAN_VIEW_OFFSETS | 904 PFCHAN_DRAWFUNC; 905 906 masterChan->setShare((cur_share | turn_on) & ~turn_off); 877 907 878 908 //masterChan->setTravFunc(PFTRAV_APP, PfAppFunc); … … 881 911 // PFCHAN_APPFUNC | PFCHAN_CULLFUNC ); 882 912 } 883 884 913 885 914 /** Returns the needed mono frame buffer config. */ … … 1189 1218 mRootWithSim = new pfScene; 1190 1219 1191 mSceneGroup = new pfGroup; // (Placeholder until app loads theirs)1220 mSceneGroup = new pfGroup; // (Placeholder until app loads theirs) 1192 1221 mRoot->addChild(mSceneGroup); // Create the base scene without sim 1193 mRootWithSim->addChild(mSceneGroup); // Create base scene with sim1222 mRootWithSim->addChild(mSceneGroup); // Create base scene with sim 1194 1223 } 1195 1224 … … 1201 1230 { 1202 1231 mApp->initScene(); 1203 if(mSceneRoot != NULL) 1232 if ( NULL != mSceneRoot ) 1233 { 1204 1234 mSceneGroup->removeChild(mSceneRoot); 1235 } 1205 1236 1206 1237 mSceneRoot = mApp->getScene(); … … 1230 1261 // for(each viewport) 1231 1262 // update Performer specific stuff. 1232 for ( unsigned disp_id=0;disp_id<mDisplays.size();disp_id++) // each display1263 for ( unsigned int disp_id = 0; disp_id < mDisplays.size(); ++disp_id ) // each display 1233 1264 { 1234 1265 pfDisplay* cur_disp = &(mDisplays[disp_id]); 1235 1266 1236 1267 vprASSERT(cur_disp->disp != NULL); 1237 for (unsigned vp=0;vp<cur_disp->viewports.size();vp++)// each viewport1268 for ( unsigned int vp = 0; vp < cur_disp->viewports.size(); ++vp ) // each viewport 1238 1269 { 1239 1270 pfViewport* pf_vp = &(cur_disp->viewports[vp]); … … 1250 1281 // --- All viewports --- // 1251 1282 //surf_vp = dynamic_cast<SurfaceViewport*>(pf_vp->viewport); 1252 //vprASSERT(surf_vp != NULL && "Could not cast supposedly surface display to SurfaceDisplay."); 1283 //vprASSERT(surf_vp != NULL && 1284 // "Could not cast supposedly surface display to SurfaceDisplay."); 1253 1285 view = cur_vp->getView(); 1254 1286 1255 if (Viewport::LEFT_EYE == view)1287 if ( Viewport::LEFT_EYE == view ) 1256 1288 { 1257 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], cur_vp->getLeftProj()); 1289 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], 1290 cur_vp->getLeftProj()); 1258 1291 } 1259 else if (Viewport::RIGHT_EYE == view)1292 else if ( Viewport::RIGHT_EYE == view ) 1260 1293 { 1261 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], cur_vp->getRightProj()); 1294 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], 1295 cur_vp->getRightProj()); 1262 1296 } 1263 else if (Viewport::STEREO == view)1297 else if ( Viewport::STEREO == view ) 1264 1298 { 1265 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], cur_vp->getLeftProj()); 1266 updatePfProjection(pf_vp->chans[pfViewport::SECONDARY], cur_vp->getRightProj()); 1299 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], 1300 cur_vp->getLeftProj()); 1301 updatePfProjection(pf_vp->chans[pfViewport::SECONDARY], 1302 cur_vp->getRightProj()); 1267 1303 } 1268 1304 else … … 1272 1308 1273 1309 // Sim viewport 1274 if (cur_vp->isSimulator())1310 if ( cur_vp->isSimulator() ) 1275 1311 { 1276 1312 SimViewport* sim_vp(NULL); … … 1278 1314 1279 1315 sim_vp = dynamic_cast<SimViewport*>(pf_vp->viewport); 1280 vprASSERT(sim_vp != NULL && "Could not cast supposed simulator display to SimDisplay."); 1316 vprASSERT(sim_vp != NULL && 1317 "Could not cast supposed simulator display to SimDisplay."); 1281 1318 1282 1319 draw_sim_i = dynamic_cast<PfSimInterface*>(sim_vp->getDrawSimInterface()); … … 1285 1322 draw_sim_i->updateSimulatorSceneGraph(); 1286 1323 } 1287 1288 1324 } 1289 1325 } … … 1362 1398 { 1363 1399 // Search surface displays 1364 for (unsigned int i=0;i<mSurfDisps.size();i++)1400 for ( unsigned int i = 0; i < mSurfDisps.size(); ++i ) 1365 1401 { 1366 1402 pfChannel* primary_chan = mSurfDisps[i].chans[pfDisp::PRIMARY]; 1367 1403 pfChannel* secondary_chan = mSurfDisps[i].chans[pfDisp::SECONDARY]; 1368 if((chan == primary_chan) || (chan == secondary_chan)) 1369 return &(mSurfDisps[i]); 1404 if ( chan == primary_chan || chan == secondary_chan ) 1405 { 1406 return &mSurfDisps[i]; 1407 } 1370 1408 } 1371 1409 1372 1410 // Search simulator displays 1373 for (unsigned int i=0;i<mSimDisps.size();i++)1411 for ( unsigned int i = 0; i < mSimDisps.size(); ++i ) 1374 1412 { 1375 1413 pfChannel* primary_chan = mSimDisps[i].chans[pfDisp::PRIMARY]; 1376 1414 pfChannel* secondary_chan = mSimDisps[i].chans[pfDisp::SECONDARY]; 1377 if((chan == primary_chan) || (chan == secondary_chan)) 1378 return &(mSimDisps[i]); 1415 if ( chan == primary_chan || chan == secondary_chan ) 1416 { 1417 return &mSimDisps[i]; 1418 } 1379 1419 } 1380 1420 … … 1383 1423 */ 1384 1424 1385 void PfDrawManager::debugDump( int debugLevel)1425 void PfDrawManager::debugDump(const int debugLevel) 1386 1426 { 1387 1427 vprDEBUG_BEGIN(vrjDBG_DRAW_MGR, debugLevel) … … 1391 1431 << vprDEBUG_FLUSH; 1392 1432 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1393 << "App: 0x" << std::hex << (void*) mApp << std::dec << std::endl1433 << "App: 0x" << std::hex << (void*) mApp << std::dec << std::endl 1394 1434 << vprDEBUG_FLUSH; 1395 1435 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1396 << "Scene: 0x" << std::hex << (void*) mRoot << std::dec << std::endl1436 << "Scene: 0x" << std::hex << (void*) mRoot << std::dec << std::endl 1397 1437 << vprDEBUG_FLUSH; 1398 1438 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1399 << "Sim scene: 0x" << std::hex << (void*) mRootWithSim << std::dec1439 << "Sim scene: 0x" << std::hex << (void*) mRootWithSim << std::dec 1400 1440 << std::endl << vprDEBUG_FLUSH; 1401 1441 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) … … 1403 1443 << vprDEBUG_FLUSH; 1404 1444 1405 for (std::vector<pfDisplay>::iterator i = mDisplays.begin(); i != mDisplays.end(); i++) 1445 typedef std::vector<pfDisplay>::iterator iter_type; 1446 for ( iter_type i = mDisplays.begin(); i != mDisplays.end(); ++i ) 1406 1447 { 1407 1448 debugDumpPfDisp(&(*i),debugLevel); … … 1412 1453 } 1413 1454 1414 1415 void PfDrawManager::debugDumpPfDisp(pfDisplay* pf_disp, int debugLevel) 1455 void PfDrawManager::debugDumpPfDisp(pfDisplay* pfDisp, const int debugLevel) 1416 1456 { 1417 1457 vprDEBUG_BEGIN(vrjDBG_DRAW_MGR, debugLevel) 1418 << "Display: 0x" << std::hex << (void*) pf _disp->disp << std::dec1458 << "Display: 0x" << std::hex << (void*) pfDisp->disp << std::dec 1419 1459 << std::endl << vprDEBUG_FLUSH; 1420 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel)1421 << "pWin: 0x" << std::hex << (void*) pf _disp->pWin << std::dec1460 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1461 << "pWin: 0x" << std::hex << (void*) pfDisp->pWin << std::dec 1422 1462 << std::endl << vprDEBUG_FLUSH; 1423 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel)1424 << "visual ID: 0x" << std::hex << pf _disp->pWin->getFBConfigId()1463 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1464 << "visual ID: 0x" << std::hex << pfDisp->pWin->getFBConfigId() 1425 1465 << std::dec << std::endl << vprDEBUG_FLUSH; 1426 1466 1427 for(unsigned vp=0; vp<pf_disp->viewports.size(); ++vp) 1428 { 1429 vprASSERT((pf_disp->viewports[vp].viewport != NULL) && "NULL viewport in pf_disp. Check if it was ever set."); 1467 for ( unsigned int vp = 0; vp < pfDisp->viewports.size(); ++vp ) 1468 { 1469 vprASSERT(pfDisp->viewports[vp].viewport != NULL && 1470 "NULL viewport in pfDisp. Check if it was ever set."); 1430 1471 1431 1472 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1432 1473 << "Viewport " << vp << vprDEBUG_FLUSH; 1433 1474 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1434 << " vp: " << *pf _disp->viewports[vp].viewport1475 << " vp: " << *pfDisp->viewports[vp].viewport 1435 1476 << vprDEBUG_FLUSH; 1436 1477 1437 for(int ch=0;ch<2;ch++) 1438 { 1439 pfChannel* cur_chan = pf_disp->viewports[vp].chans[ch]; 1440 unsigned chan_mask(0); 1441 if(cur_chan != NULL) 1478 for ( int ch = 0; ch < 2; ++ch ) 1479 { 1480 pfChannel* cur_chan = pfDisp->viewports[vp].chans[ch]; 1481 unsigned int chan_mask(0); 1482 if ( cur_chan != NULL ) 1483 { 1442 1484 chan_mask = cur_chan->getShare(); 1485 } 1443 1486 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1444 << "chan " << ch << " -- " << std::hex << (void*) cur_chan 1445 << std::dec << " shared: FOV:" << (chan_mask & PFCHAN_FOV) 1446 << " Scene:" << (chan_mask & PFCHAN_SCENE) 1447 << " AppFunc:" << (chan_mask & PFCHAN_APPFUNC) 1448 << " SwapBuff:" << (chan_mask & PFCHAN_SWAPBUFFERS) 1449 << " SwapBuff-HW:" << (chan_mask & PFCHAN_SWAPBUFFERS_HW) 1450 << std::endl << vprDEBUG_FLUSH; 1451 } 1452 } 1453 1454 vprDEBUG_CONT_END(vrjDBG_DRAW_MGR,debugLevel) << vprDEBUG_FLUSH; 1455 } 1456 1457 1487 << "chan " << ch << " -- " << std::hex << (void*) cur_chan 1488 << std::dec << " shared: FOV:" << (chan_mask & PFCHAN_FOV) 1489 << " Scene:" << (chan_mask & PFCHAN_SCENE) 1490 << " AppFunc:" << (chan_mask & PFCHAN_APPFUNC) 1491 << " SwapBuff:" << (chan_mask & PFCHAN_SWAPBUFFERS) 1492 << " SwapBuff-HW:" << (chan_mask & PFCHAN_SWAPBUFFERS_HW) 1493 << std::endl << vprDEBUG_FLUSH; 1494 } 1495 } 1496 1497 vprDEBUG_CONT_END(vrjDBG_DRAW_MGR, debugLevel) << vprDEBUG_FLUSH; 1498 } 1458 1499 1459 1500 // Config function called in draw proc after window is set up … … 1482 1523 } 1483 1524 1484 1485 1525 /* 1486 void PfAppFunc(pfChannel *chan, void* chandata)1526 void PfAppFunc(pfChannel* chan, void* chandata) 1487 1527 { 1488 1528 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) … … 1493 1533 1494 1534 pfChannel* master_chan = PfDrawManager::instance()->mMasterChan; 1495 if (master_chan == chan)1535 if ( master_chan == chan ) 1496 1536 { 1497 1537 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) 1498 1538 << "I am the master of the house:\n" << vprDEBUG_FLUSH; 1499 if (PfDrawManager::instance()->mPfAppCalled == false) // Haven't called it yet1539 if ( PfDrawManager::instance()->mPfAppCalled == false ) // Haven't called it yet 1500 1540 { 1501 1541 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) … …
