Changeset 19938
- Timestamp:
- 04/10/07 09:54:25 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
juggler/trunk/modules/vrjuggler/vrj/Draw/Pf/PfDrawManager.cpp
r19937 r19938 74 74 75 75 // Draw Callbacks 76 void PfDrawFuncStereoLeft(pfChannel *chan, void* chandata);77 void PfDrawFuncStereoRight(pfChannel *chan, void* chandata);78 void PfDrawFuncMonoBackbuffer(pfChannel *chan, void* chandata);76 void PfDrawFuncStereoLeft(pfChannel* chan, void* chandata); 77 void PfDrawFuncStereoRight(pfChannel* chan, void* chandata); 78 void PfDrawFuncMonoBackbuffer(pfChannel* chan, void* chandata); 79 79 //void PfDrawFuncSimulator(pfChannel* chan, void* chandata); 80 //void PfAppFunc(pfChannel *chan, void* chandata);81 82 83 void PfPipeSwapFunc(pfPipe *p, pfPipeWindow *pw);80 //void PfAppFunc(pfChannel* chan, void* chandata); 81 82 83 void PfPipeSwapFunc(pfPipe* p, pfPipeWindow* pw); 84 84 85 85 vprSingletonImp(PfDrawManager); … … 88 88 { 89 89 //TODO: Add thread safety. 90 for ( std::vector<PfInputHandler*>::iterator itr = mPfInputHandlers.begin();91 itr != mPfInputHandlers.end() ; itr++)90 typedef std::vector<PfInputHandler*>::iterator iter_type; 91 for ( iter_type itr = mPfInputHandlers.begin(); itr != mPfInputHandlers.end(); ++itr ) 92 92 { 93 93 delete *itr; … … 117 117 // pipes when creating a new display_system element is 0. It needs to be this 118 118 // because we can not fill in the list of pipes with default values. 119 if (mNumPipes < 1)119 if ( mNumPipes < 1 ) 120 120 { 121 121 mNumPipes = 1; 122 122 } 123 123 124 for ( unsigned int i=0;i<mNumPipes;i++)124 for ( unsigned int i = 0; i < mNumPipes; ++i ) 125 125 { 126 126 std::string cur_disp_name = "-1"; 127 127 128 // NOTE: ConfigElements return the default value for a property if a value is129 // not present. So if a pipe string is not specified for this pipe then130 // it gets the default value of "-1".128 // NOTE: ConfigElements return the default value for a property if a 129 // value is not present. So if a pipe string is not specified for 130 // this pipe then it gets the default value of "-1". 131 131 mPipeStrs.push_back(element->getProperty<std::string>("x11_pipes", i)); 132 132 133 if (mPipeStrs[i] == cur_disp_name) // Use display env133 if ( mPipeStrs[i] == cur_disp_name ) // Use display env 134 134 { 135 135 std::string display_env; … … 146 146 << vprDEBUG_FLUSH; 147 147 } 148 148 149 return true; 149 150 } … … 173 174 pfFrame(); 174 175 175 for (std::vector<PfInputHandler*>::iterator itr = mPfInputHandlers.begin();176 itr != mPfInputHandlers.end() ; itr++)176 typedef std::vector<PfInputHandler*>::iterator iter_type; 177 for ( iter_type itr = mPfInputHandlers.begin(); itr != mPfInputHandlers.end(); ++itr ) 177 178 { 178 179 (*itr)->checkEvents(); 179 180 } 180 181 } 181 182 182 183 183 // XXX: Hack for now … … 187 187 // for(each viewport) 188 188 // for(each channel) 189 for (unsigned int dispIndex=0;dispIndex<mDisplays.size();dispIndex++)190 { 191 for (unsigned vp=0;vp<mDisplays[dispIndex].viewports.size();vp++)192 { 193 for (unsigned ch=0;ch<2;ch++)189 for ( unsigned int dispIndex = 0; dispIndex < mDisplays.size(); ++dispIndex ) 190 { 191 for ( unsigned int vp = 0; vp < mDisplays[dispIndex].viewports.size(); ++vp ) 192 { 193 for ( unsigned int ch = 0; ch < 2; ++ch ) 194 194 { 195 if(mDisplays[dispIndex].viewports[vp].chans[ch] != NULL) 195 if ( mDisplays[dispIndex].viewports[vp].chans[ch] != NULL ) 196 { 196 197 mApp->appChanFunc(mDisplays[dispIndex].viewports[vp].chans[ch]); 198 } 197 199 } 198 200 } 199 201 } 200 202 } 201 202 203 203 204 /** … … 206 207 * @post dynamic_cast<> of the app to a Pf app. 207 208 */ 208 void PfDrawManager::setApp(App* _app)209 void PfDrawManager::setApp(App* app) 209 210 { 210 211 //vprASSERT(app != NULL); 211 mApp = dynamic_cast<PfApp*>(_app); 212 if(mPfHasForked) 213 initAppGraph(); // If pf is already started, then intialize the app scene graph 214 212 mApp = dynamic_cast<PfApp*>(app); 213 214 // If pf is already started, then intialize the app scene graph. 215 if ( mPfHasForked ) 216 { 217 initAppGraph(); 218 } 215 219 } 216 220 … … 226 230 pfuInitUtil(); 227 231 228 // XXX: This call should really be triggered by a change in draw manager or something 232 // XXX: This call should really be triggered by a change in draw manager or 233 // something. 229 234 vprASSERT(mDisplayManager != NULL); 230 configDisplaySystem(mDisplayManager->getDisplaySystemElement()); // Configure all the display system stuff 235 236 // Configure all the display system stuff. 237 configDisplaySystem(mDisplayManager->getDisplaySystemElement()); 231 238 232 239 mApp->preForkInit(); … … 246 253 #else 247 254 // If we are running in a cluster then we must run in single process mode. 248 if (jccl::ConfigManager::instance()->isElementTypeInPendingList("cluster_manager") ||249 jccl::ConfigManager::instance()->isElementTypeInActiveList("cluster_manager"))255 if ( jccl::ConfigManager::instance()->isElementTypeInPendingList("cluster_manager") || 256 jccl::ConfigManager::instance()->isElementTypeInActiveList("cluster_manager") ) 250 257 { 251 258 vprDEBUG_BEGIN(vrjDBG_DRAW_MGR, vprDBG_STATE_LVL) … … 263 270 #endif 264 271 265 // We can not init head and wand model loaders since they are loaded in PfBasicSimInterface 272 // We can not init head and wand model loaders since they are loaded in 273 // PfBasicSimInterface. 266 274 // initLoaders(); // Must call before pfConfig 267 275 … … 275 283 276 284 // Initialize the pipes that the system may need 277 // If we don't do this, then pf automatically give each pipe a big black channel 285 // If we don't do this, then pf automatically give each pipe a big black 286 // channel. 278 287 initPipes(); 279 288 280 289 initPerformerGraph(); // Create the other scene graph nodes 281 if(mApp != NULL) 290 if ( NULL != mApp ) 291 { 282 292 initAppGraph(); // App was already set, but pf was not loaded. So load graph now 283 293 } 284 294 285 295 vprASSERT(mRoot != NULL && "We have a NULL root in PfDrawManager"); 286 vprASSERT(mRootWithSim != NULL && "We have a NULL sim root scene in PfDrawManager"); 287 vprASSERT(mSceneRoot != NULL && "We have a NULL root scene in PfDrawManager"); 296 vprASSERT(mRootWithSim != NULL && 297 "We have a NULL sim root scene in PfDrawManager"); 298 vprASSERT(mSceneRoot != NULL && 299 "We have a NULL root scene in PfDrawManager"); 288 300 289 301 //pfFrame(); … … 300 312 * Gets a Performer pipe. 301 313 * 302 * @pre pipe _num < mNumPipes314 * @pre pipeNum < mNumPipes 303 315 * Fork must have happened. 304 316 */ 305 pfPipe* PfDrawManager::getPfPipe(unsigned pipe_num)317 pfPipe* PfDrawManager::getPfPipe(unsigned int pipeNum) 306 318 { 307 319 vprASSERT((mPfHasForked) && "Tried to get pipe before forking happened"); 308 vprASSERT((pipe _num < mNumPipes) && "Tried to request out of bounds pipe");309 vprASSERT((pipe _num < mPipes.size()) && "Tried to get out of range pipe");310 vprASSERT((NULL != mPipes[pipe _num]) && "Have NULL pipe");320 vprASSERT((pipeNum < mNumPipes) && "Tried to request out of bounds pipe"); 321 vprASSERT((pipeNum < mPipes.size()) && "Tried to get out of range pipe"); 322 vprASSERT((NULL != mPipes[pipeNum]) && "Have NULL pipe"); 311 323 312 324 // Print an error message if an invalid pipe was requested. This will 313 325 // probably only happen when a configuration is broken. 314 if ( pipe _num >= mNumPipes || pipe_num >= mPipes.size() ||315 NULL == mPipes[pipe _num] )326 if ( pipeNum >= mNumPipes || pipeNum >= mPipes.size() || 327 NULL == mPipes[pipeNum] ) 316 328 { 317 329 vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL) 318 330 << clrOutNORM(clrRED, "ERROR") 319 << ": Invalid pipe number (" << pipe _num << ") requested. "331 << ": Invalid pipe number (" << pipeNum << ") requested. " 320 332 << "Check display system configuration.\n" << vprDEBUG_FLUSH; 321 333 return NULL; … … 324 336 { 325 337 // Return the actual pipe 326 return mPipes[pipe _num];338 return mPipes[pipeNum]; 327 339 } 328 340 } … … 335 347 mPipes.resize(mNumPipes, NULL); // Resize the vector 336 348 337 for (unsigned pipe_num=0; pipe_num<mNumPipes; pipe_num++)349 for ( unsigned int pipe_num = 0; pipe_num < mNumPipes; ++pipe_num ) 338 350 { 339 351 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL) … … 349 361 350 362 pfPipeWindow* pw = allocatePipeWin(pipe_num); // new pfPipeWindow(mPipes[pipe_num]); 351 pw->setOriginSize(0, 0,1,1);363 pw->setOriginSize(0, 0, 1, 1); 352 364 353 365 // XXX: Set the swap func 354 mPipes[pipe_num]->setSwapFunc( PfPipeSwapFunc );// Set to the given swap func366 mPipes[pipe_num]->setSwapFunc(PfPipeSwapFunc); // Set to the given swap func 355 367 } 356 368 } … … 365 377 { 366 378 vprASSERT(disp.get() != NULL); // Can't add a null display 367 vprASSERT((true == mPfHasForked) && "Trying to add display when performer has not been initialized"); 379 vprASSERT(mPfHasForked && 380 "Trying to add display when performer has not been initialized"); 368 381 369 382 // For the display … … 408 421 // Setup window border 409 422 if (disp->shouldDrawBorder()) 423 { 410 424 pf_disp.pWin->setName(disp->getName().c_str()); // Give the window a name 425 } 411 426 else 412 pf_disp.pWin->setMode(PFWIN_NOBORDER, 1); // Get rid of that border 427 { 428 pf_disp.pWin->setMode(PFWIN_NOBORDER, 1); // Get rid of that border 429 } 413 430 414 431 jccl::ConfigElementPtr fb_elt = disp->getGlFrameBufferConfig(); … … 484 501 // - Setup master chans 485 502 Viewport* viewport = NULL; 486 unsignednum_vps = disp->getNumViewports();503 const unsigned int num_vps = disp->getNumViewports(); 487 504 488 505 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL) 489 506 << " Num viewports: " << num_vps << std::endl << vprDEBUG_FLUSH; 490 507 491 for (unsigned vp_num=0; vp_num < num_vps; vp_num++)508 for ( unsigned int vp_num = 0; vp_num < num_vps; ++vp_num ) 492 509 { 493 510 viewport = disp->getViewport(vp_num); 494 511 495 if (viewport->isActive()) // is viewport active512 if ( viewport->isActive() ) // is viewport active 496 513 { 497 514 //Viewport::View view = viewport->getView(); 498 pfViewport pf_viewport; // The viewport to build up515 pfViewport pf_viewport; // The viewport to build up 499 516 pf_viewport.viewport = viewport; 500 517 float vp_ox, vp_oy, vp_sx, vp_sy; … … 504 521 viewport->getOriginAndSize(vp_ox, vp_oy, vp_sx, vp_sy); 505 522 pf_viewport.chans[pfViewport::PRIMARY] = new pfChannel(pipe); 506 pf_viewport.chans[pfViewport::PRIMARY]->setViewport(vp_ox, vp_ox+vp_sx, vp_oy, vp_oy+vp_sy); 523 pf_viewport.chans[pfViewport::PRIMARY]->setViewport(vp_ox, 524 vp_ox + vp_sx, 525 vp_oy, 526 vp_oy + vp_sy); 507 527 pf_disp.pWin->addChan(pf_viewport.chans[pfViewport::PRIMARY]); 508 528 509 529 // Secondary channel - (Right in stereo) 510 if (disp->isStereoRequested())530 if ( disp->isStereoRequested() ) 511 531 { 512 532 pf_viewport.chans[pfViewport::SECONDARY] = new pfChannel(pipe); 513 pf_viewport.chans[pfViewport::SECONDARY]->setViewport(vp_ox, vp_ox+vp_sx, vp_oy, vp_oy+vp_sy); 533 pf_viewport.chans[pfViewport::SECONDARY]->setViewport(vp_ox, 534 vp_ox + vp_sx, 535 vp_oy, 536 vp_oy + vp_sy); 514 537 pf_disp.pWin->addChan(pf_viewport.chans[pfViewport::SECONDARY]); 515 538 } 516 539 517 540 // Set draw function 518 if (disp->isStereoRequested())541 if ( disp->isStereoRequested() ) 519 542 { 520 pf_viewport.chans[pfViewport::PRIMARY]->setTravFunc(PFTRAV_DRAW, PfDrawFuncStereoLeft); 521 pf_viewport.chans[pfViewport::SECONDARY]->setTravFunc(PFTRAV_DRAW, PfDrawFuncStereoRight); 543 pf_viewport.chans[pfViewport::PRIMARY]->setTravFunc(PFTRAV_DRAW, 544 PfDrawFuncStereoLeft); 545 pf_viewport.chans[pfViewport::SECONDARY]->setTravFunc(PFTRAV_DRAW, 546 PfDrawFuncStereoRight); 522 547 } 523 548 else 524 549 { 525 pf_viewport.chans[pfViewport::PRIMARY]->setTravFunc(PFTRAV_DRAW, PfDrawFuncMonoBackbuffer); 550 pf_viewport.chans[pfViewport::PRIMARY]->setTravFunc(PFTRAV_DRAW, 551 PfDrawFuncMonoBackbuffer); 526 552 } 527 553 528 554 // if surface ==> Setup surface channels 529 if ( viewport->isSurface())555 if ( viewport->isSurface() ) 530 556 { 531 557 vprASSERT(pf_viewport.chans[pfViewport::PRIMARY] != NULL); 532 558 533 559 // Primary 534 if (NULL == mSurfMasterChan) // If NULL, then add us as the new one560 if ( NULL == mSurfMasterChan ) // If NULL, then add us as the new one 535 561 { 536 562 mSurfMasterChan = pf_viewport.chans[pfViewport::PRIMARY]; … … 546 572 547 573 // Secondary 548 if (NULL != pf_viewport.chans[pfViewport::SECONDARY])574 if ( NULL != pf_viewport.chans[pfViewport::SECONDARY] ) 549 575 { 550 576 mSurfChannels.push_back(pf_viewport.chans[pfViewport::SECONDARY]); 551 577 mSurfMasterChan->attach(pf_viewport.chans[pfViewport::SECONDARY]); 552 578 } 553 554 579 } 555 580 // if sim ==> setup sim channels 556 else if (viewport->isSimulator())581 else if ( viewport->isSimulator() ) 557 582 { 558 583 // -- Finish Simulator setup … … 566 591 567 592 // Create the simulator stuff 568 vprASSERT(1 == vp_element->getNum("simulator_plugin") && "You must supply a simulator plugin."); 593 vprASSERT(1 == vp_element->getNum("simulator_plugin") && 594 "You must supply a simulator plugin."); 569 595 570 596 jccl::ConfigElementPtr sim_element = … … 590 616 591 617 // Primary 592 if (NULL == mSimMasterChan) // If NULL, then make us the master618 if ( NULL == mSimMasterChan ) // If NULL, then make us the master 593 619 { 594 620 mSimMasterChan = pf_viewport.chans[pfViewport::PRIMARY]; … … 604 630 605 631 // Secondary 606 if (NULL != pf_viewport.chans[pfViewport::SECONDARY])632 if ( NULL != pf_viewport.chans[pfViewport::SECONDARY] ) 607 633 { 608 634 mSimChannels.push_back(pf_viewport.chans[pfViewport::SECONDARY]); … … 613 639 // Add viewport to the display list 614 640 pf_disp.viewports.push_back(pf_viewport); 615 616 641 } // is viewport active 617 642 } // for each viewport … … 629 654 // Performer says that if you trigger a window from the applciation proccess 630 655 // you must wait for the window to open during the draw process. 631 while ( !pfIsPWinOpen( pf_disp.pWin) )656 while ( ! pfIsPWinOpen(pf_disp.pWin) ) 632 657 { 633 658 pfFrame(); 634 vpr::System::usleep( 500 ); 635 } 636 637 PfInputHandler* new_input_handler = new PfInputHandler(pf_disp.pWin, disp->getName()); 659 vpr::System::usleep(500); 660 } 661 662 PfInputHandler* new_input_handler = 663 new PfInputHandler(pf_disp.pWin, disp->getName()); 638 664 639 665 // Configure the Performer window to accept events. … … 641 667 new_input_handler->config(display_elt, disp); 642 668 643 644 669 mPfInputHandlers.push_back(new_input_handler); 645 670 646 if (pf_disp.disp->shouldHideMouse())671 if ( pf_disp.disp->shouldHideMouse() ) 647 672 { 648 673 pfuLoadPWinCursor(pf_disp.pWin, PFU_CURSOR_OFF); … … 680 705 */ 681 706 682 683 684 685 707 /** 686 708 * Callback when display is removed to display manager. … … 704 726 } 705 727 #else 706 std::vector<pfDisplay>::iterator disp_i = std::find_if(mDisplays.begin(), mDisplays.end(), 707 std::compose1( std::bind2nd( std::equal_to<DisplayPtr>(),disp), 708 pfDisplay_disp()) ); 728 std::vector<pfDisplay>::iterator disp_i = 729 std::find_if(mDisplays.begin(), mDisplays.end(), 730 std::compose1(std::bind2nd(std::equal_to<DisplayPtr>(), disp), 731 pfDisplay_disp())); 709 732 #endif 710 733 711 712 if(mDisplays.end() == disp_i) 734 if ( mDisplays.end() == disp_i ) 713 735 { 714 736 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) … … 718 740 } 719 741 720 721 742 // Release the pfDisplay 722 743 releaseDisplay(*disp_i); … … 729 750 { 730 751 // Release all viewports 731 for(std::vector<pfViewport>::iterator i=disp.viewports.begin(); i != disp.viewports.end(); i++) 752 typedef std::vector<pfViewport>::iterator iter_type; 753 for ( iter_type i = disp.viewports.begin(); i != disp.viewports.end(); ++i ) 732 754 { 733 755 releaseViewport(disp, *i); … … 738 760 } 739 761 740 741 762 void PfDrawManager::releaseViewport(pfDisplay& disp, pfViewport& vp) 742 763 { … … 744 765 745 766 // Release the channel stuff 746 for (int i=0;i<2;i++)767 for ( int i = 0; i < 2; ++i ) 747 768 { 748 769 pfChannel* chan = vp.chans[i]; 749 770 750 771 // if we have a channel to delete 751 if (chan != NULL)752 { 753 if (vp.viewport->isSurface()) // SURFACE display772 if ( chan != NULL ) 773 { 774 if ( vp.viewport->isSurface() ) // SURFACE display 754 775 { 755 776 // Remove the channel from the list of channels 756 chan_i = std::find(mSurfChannels.begin(), mSurfChannels.end(), chan); 757 if(chan_i == mSurfChannels.end()) 777 chan_i = std::find(mSurfChannels.begin(), mSurfChannels.end(), 778 chan); 779 780 if ( chan_i == mSurfChannels.end() ) 758 781 { 759 782 vprASSERT(false && "Trying to remove a non-existant channel"); … … 764 787 765 788 // Check if we were the master 766 if (chan == mSurfMasterChan)789 if ( chan == mSurfMasterChan ) 767 790 { 768 mSurfMasterChan = NULL; // Get new master channel 769 if(mSurfChannels.size() > 0) 791 mSurfMasterChan = NULL; // Get new master channel 792 if ( mSurfChannels.size() > 0 ) 793 { 770 794 mSurfMasterChan = mSurfChannels[0]; 795 } 771 796 } 772 797 773 if(mSurfMasterChan != NULL) // Dettach from the channel 798 if ( mSurfMasterChan != NULL ) // Dettach from the channel 799 { 774 800 chan->detach(mSurfMasterChan); 801 } 775 802 } 776 else if (vp.viewport->isSimulator()) // SIMULATOR display803 else if ( vp.viewport->isSimulator() ) // SIMULATOR display 777 804 { 778 805 // Remove the channel from the list of channels 779 806 chan_i = std::find(mSimChannels.begin(), mSimChannels.end(), chan); 780 if (chan_i == mSimChannels.end())807 if ( chan_i == mSimChannels.end() ) 781 808 { 782 809 vprASSERT(false && "Trying to remove a non-existant channel"); … … 787 814 788 815 // Check if we were the master 789 if (chan == mSimMasterChan)816 if ( chan == mSimMasterChan ) 790 817 { 791 mSimMasterChan = NULL; // Get new master channel 792 if(mSimChannels.size() > 0) 818 mSimMasterChan = NULL; // Get new master channel 819 if ( mSimChannels.size() > 0 ) 820 { 793 821 mSimMasterChan = mSimChannels[0]; 822 } 794 823 } 795 824 796 if(mSimMasterChan != NULL) // Dettach from the channel 825 if ( mSimMasterChan != NULL ) // Dettach from the channel 826 { 797 827 chan->detach(mSimMasterChan); 828 } 798 829 } 799 830 800 831 chan->setScene(NULL); 801 832 disp.pWin->removeChan(chan); // Remove channel from pwin 802 pfDelete( chan); // Delete the channel 803 } 804 } 805 } 806 807 833 pfDelete(chan); // Delete the channel 834 } 835 } 836 } 808 837 809 838 // Get a pipe window to use 810 // This either allocates a new pipe window or grabs an unused one that was previously released 811 pfPipeWindow* PfDrawManager::allocatePipeWin(unsigned pipeNum) 839 // This either allocates a new pipe window or grabs an unused one that was 840 // previously released 841 pfPipeWindow* PfDrawManager::allocatePipeWin(const unsigned int pipeNum) 812 842 { 813 843 pfPipeWindow* ret_val; … … 819 849 } 820 850 821 if (mPipeWindows[pipeNum].size() > 0) // Is one available851 if ( mPipeWindows[pipeNum].size() > 0 ) // Is one available 822 852 { 823 853 ret_val = mPipeWindows[pipeNum].back(); … … 826 856 else 827 857 { 828 ret_val = new pfPipeWindow(getPfPipe(pipeNum)); // Allocate a new one858 ret_val = new pfPipeWindow(getPfPipe(pipeNum)); // Allocate a new one 829 859 } 830 860 … … 835 865 836 866 // Just store the old pipe window in the list 837 void PfDrawManager::releasePipeWin(pfPipeWindow* pipeWin, unsigned pipeNum) 867 void PfDrawManager::releasePipeWin(pfPipeWindow* pipeWin, 868 const unsigned int pipeNum) 838 869 { 839 870 mPipeWindows[pipeNum].push_back(pipeWin); 840 871 } 841 842 843 872 844 873 // Initialize the parameters of the master channel … … 859 888 // Set the Channel attribs based on cur settings 860 889 // 861 unsigned cur_share = masterChan->getShare(); // Get current setting, and OR the new stuff on 862 unsigned turn_on = ( PFCHAN_NEARFAR | PFCHAN_EARTHSKY | 863 PFCHAN_STRESS | PFCHAN_LOD | PFCHAN_SWAPBUFFERS | 864 PFCHAN_APPFUNC | PFCHAN_SCENE | PFCHAN_CULLFUNC | 865 PFCHAN_STATS_DRAWMODE); 866 unsigned turn_off = ( PFCHAN_FOV | 867 PFCHAN_VIEW | 868 PFCHAN_VIEW_OFFSETS | 869 PFCHAN_DRAWFUNC ); 870 871 masterChan->setShare((cur_share | turn_on) &(~turn_off)); 890 const unsigned int cur_share = masterChan->getShare(); // Get current setting, and OR the new stuff on 891 const unsigned int turn_on = PFCHAN_NEARFAR | PFCHAN_EARTHSKY | 892 PFCHAN_STRESS | PFCHAN_LOD | 893 PFCHAN_SWAPBUFFERS | PFCHAN_APPFUNC | 894 PFCHAN_SCENE | PFCHAN_CULLFUNC | 895 PFCHAN_STATS_DRAWMODE; 896 const unsigned int turn_off = PFCHAN_FOV | 897 PFCHAN_VIEW | 898 PFCHAN_VIEW_OFFSETS | 899 PFCHAN_DRAWFUNC; 900 901 masterChan->setShare((cur_share | turn_on) & ~turn_off); 872 902 873 903 //masterChan->setTravFunc(PFTRAV_APP, PfAppFunc); … … 876 906 // PFCHAN_APPFUNC | PFCHAN_CULLFUNC ); 877 907 } 878 879 908 880 909 /** Returns the needed mono frame buffer config. */ … … 1184 1213 mRootWithSim = new pfScene; 1185 1214 1186 mSceneGroup = new pfGroup; // (Placeholder until app loads theirs)1215 mSceneGroup = new pfGroup; // (Placeholder until app loads theirs) 1187 1216 mRoot->addChild(mSceneGroup); // Create the base scene without sim 1188 mRootWithSim->addChild(mSceneGroup); // Create base scene with sim1217 mRootWithSim->addChild(mSceneGroup); // Create base scene with sim 1189 1218 } 1190 1219 … … 1196 1225 { 1197 1226 mApp->initScene(); 1198 if(mSceneRoot != NULL) 1227 if ( NULL != mSceneRoot ) 1228 { 1199 1229 mSceneGroup->removeChild(mSceneRoot); 1230 } 1200 1231 1201 1232 mSceneRoot = mApp->getScene(); … … 1225 1256 // for(each viewport) 1226 1257 // update Performer specific stuff. 1227 for ( unsigned disp_id=0;disp_id<mDisplays.size();disp_id++) // each display1258 for ( unsigned int disp_id = 0; disp_id < mDisplays.size(); ++disp_id ) // each display 1228 1259 { 1229 1260 pfDisplay* cur_disp = &(mDisplays[disp_id]); 1230 1261 1231 1262 vprASSERT(cur_disp->disp != NULL); 1232 for (unsigned vp=0;vp<cur_disp->viewports.size();vp++)// each viewport1263 for ( unsigned int vp = 0; vp < cur_disp->viewports.size(); ++vp ) // each viewport 1233 1264 { 1234 1265 pfViewport* pf_vp = &(cur_disp->viewports[vp]); … … 1245 1276 // --- All viewports --- // 1246 1277 //surf_vp = dynamic_cast<SurfaceViewport*>(pf_vp->viewport); 1247 //vprASSERT(surf_vp != NULL && "Could not cast supposedly surface display to SurfaceDisplay."); 1278 //vprASSERT(surf_vp != NULL && 1279 // "Could not cast supposedly surface display to SurfaceDisplay."); 1248 1280 view = cur_vp->getView(); 1249 1281 1250 if (Viewport::LEFT_EYE == view)1282 if ( Viewport::LEFT_EYE == view ) 1251 1283 { 1252 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], cur_vp->getLeftProj()); 1284 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], 1285 cur_vp->getLeftProj()); 1253 1286 } 1254 else if (Viewport::RIGHT_EYE == view)1287 else if ( Viewport::RIGHT_EYE == view ) 1255 1288 { 1256 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], cur_vp->getRightProj()); 1289 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], 1290 cur_vp->getRightProj()); 1257 1291 } 1258 else if (Viewport::STEREO == view)1292 else if ( Viewport::STEREO == view ) 1259 1293 { 1260 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], cur_vp->getLeftProj()); 1261 updatePfProjection(pf_vp->chans[pfViewport::SECONDARY], cur_vp->getRightProj()); 1294 updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], 1295 cur_vp->getLeftProj()); 1296 updatePfProjection(pf_vp->chans[pfViewport::SECONDARY], 1297 cur_vp->getRightProj()); 1262 1298 } 1263 1299 else … … 1267 1303 1268 1304 // Sim viewport 1269 if (cur_vp->isSimulator())1305 if ( cur_vp->isSimulator() ) 1270 1306 { 1271 1307 SimViewport* sim_vp(NULL); … … 1273 1309 1274 1310 sim_vp = dynamic_cast<SimViewport*>(pf_vp->viewport); 1275 vprASSERT(sim_vp != NULL && "Could not cast supposed simulator display to SimDisplay."); 1311 vprASSERT(sim_vp != NULL && 1312 "Could not cast supposed simulator display to SimDisplay."); 1276 1313 1277 1314 draw_sim_i = … … 1284 1321 draw_sim_i->updateSimulatorSceneGraph(); 1285 1322 } 1286 1287 1323 } 1288 1324 } … … 1361 1397 { 1362 1398 // Search surface displays 1363 for (unsigned int i=0;i<mSurfDisps.size();i++)1399 for ( unsigned int i = 0; i < mSurfDisps.size(); ++i ) 1364 1400 { 1365 1401 pfChannel* primary_chan = mSurfDisps[i].chans[pfDisp::PRIMARY]; 1366 1402 pfChannel* secondary_chan = mSurfDisps[i].chans[pfDisp::SECONDARY]; 1367 if((chan == primary_chan) || (chan == secondary_chan)) 1368 return &(mSurfDisps[i]); 1403 if ( chan == primary_chan || chan == secondary_chan ) 1404 { 1405 return &mSurfDisps[i]; 1406 } 1369 1407 } 1370 1408 1371 1409 // Search simulator displays 1372 for (unsigned int i=0;i<mSimDisps.size();i++)1410 for ( unsigned int i = 0; i < mSimDisps.size(); ++i ) 1373 1411 { 1374 1412 pfChannel* primary_chan = mSimDisps[i].chans[pfDisp::PRIMARY]; 1375 1413 pfChannel* secondary_chan = mSimDisps[i].chans[pfDisp::SECONDARY]; 1376 if((chan == primary_chan) || (chan == secondary_chan)) 1377 return &(mSimDisps[i]); 1414 if ( chan == primary_chan || chan == secondary_chan ) 1415 { 1416 return &mSimDisps[i]; 1417 } 1378 1418 } 1379 1419 … … 1382 1422 */ 1383 1423 1384 void PfDrawManager::debugDump( int debugLevel)1424 void PfDrawManager::debugDump(const int debugLevel) 1385 1425 { 1386 1426 vprDEBUG_BEGIN(vrjDBG_DRAW_MGR, debugLevel) … … 1390 1430 << vprDEBUG_FLUSH; 1391 1431 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1392 << "App: 0x" << std::hex << (void*) mApp << std::dec << std::endl1432 << "App: 0x" << std::hex << (void*) mApp << std::dec << std::endl 1393 1433 << vprDEBUG_FLUSH; 1394 1434 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1395 << "Scene: 0x" << std::hex << (void*) mRoot << std::dec << std::endl1435 << "Scene: 0x" << std::hex << (void*) mRoot << std::dec << std::endl 1396 1436 << vprDEBUG_FLUSH; 1397 1437 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1398 << "Sim scene: 0x" << std::hex << (void*) mRootWithSim << std::dec1438 << "Sim scene: 0x" << std::hex << (void*) mRootWithSim << std::dec 1399 1439 << std::endl << vprDEBUG_FLUSH; 1400 1440 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) … … 1402 1442 << vprDEBUG_FLUSH; 1403 1443 1404 for (std::vector<pfDisplay>::iterator i = mDisplays.begin(); i != mDisplays.end(); i++) 1444 typedef std::vector<pfDisplay>::iterator iter_type; 1445 for ( iter_type i = mDisplays.begin(); i != mDisplays.end(); ++i ) 1405 1446 { 1406 1447 debugDumpPfDisp(&(*i),debugLevel); … … 1411 1452 } 1412 1453 1413 1414 void PfDrawManager::debugDumpPfDisp(pfDisplay* pf_disp, int debugLevel) 1454 void PfDrawManager::debugDumpPfDisp(pfDisplay* pfDisp, const int debugLevel) 1415 1455 { 1416 1456 vprDEBUG_BEGIN(vrjDBG_DRAW_MGR, debugLevel) 1417 << "Display: 0x" << std::hex << (void*) pf _disp->disp.get() << std::dec1457 << "Display: 0x" << std::hex << (void*) pfDisp->disp.get() << std::dec 1418 1458 << std::endl << vprDEBUG_FLUSH; 1419 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel)1420 << "pWin: 0x" << std::hex << (void*) pf _disp->pWin << std::dec1459 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1460 << "pWin: 0x" << std::hex << (void*) pfDisp->pWin << std::dec 1421 1461 << std::endl << vprDEBUG_FLUSH; 1422 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel)1423 << "visual ID: 0x" << std::hex << pf _disp->pWin->getFBConfigId()1462 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1463 << "visual ID: 0x" << std::hex << pfDisp->pWin->getFBConfigId() 1424 1464 << std::dec << std::endl << vprDEBUG_FLUSH; 1425 1465 1426 for(unsigned vp=0; vp<pf_disp->viewports.size(); ++vp) 1427 { 1428 vprASSERT((pf_disp->viewports[vp].viewport != NULL) && "NULL viewport in pf_disp. Check if it was ever set."); 1466 for ( unsigned int vp = 0; vp < pfDisp->viewports.size(); ++vp ) 1467 { 1468 vprASSERT(pfDisp->viewports[vp].viewport != NULL && 1469 "NULL viewport in pfDisp. Check if it was ever set."); 1429 1470 1430 1471 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1431 1472 << "Viewport " << vp << vprDEBUG_FLUSH; 1432 1473 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1433 << " vp: " << *pf _disp->viewports[vp].viewport1474 << " vp: " << *pfDisp->viewports[vp].viewport 1434 1475 << vprDEBUG_FLUSH; 1435 1476 1436 for(int ch=0;ch<2;ch++) 1437 { 1438 pfChannel* cur_chan = pf_disp->viewports[vp].chans[ch]; 1439 unsigned chan_mask(0); 1440 if(cur_chan != NULL) 1477 for ( int ch = 0; ch < 2; ++ch ) 1478 { 1479 pfChannel* cur_chan = pfDisp->viewports[vp].chans[ch]; 1480 unsigned int chan_mask(0); 1481 if ( cur_chan != NULL ) 1482 { 1441 1483 chan_mask = cur_chan->getShare(); 1484 } 1442 1485 vprDEBUG_NEXT(vrjDBG_DRAW_MGR, debugLevel) 1443 << "chan " << ch << " -- " << std::hex << (void*) cur_chan 1444 << std::dec << " shared: FOV:" << (chan_mask & PFCHAN_FOV) 1445 << " Scene:" << (chan_mask & PFCHAN_SCENE) 1446 << " AppFunc:" << (chan_mask & PFCHAN_APPFUNC) 1447 << " SwapBuff:" << (chan_mask & PFCHAN_SWAPBUFFERS) 1448 << " SwapBuff-HW:" << (chan_mask & PFCHAN_SWAPBUFFERS_HW) 1449 << std::endl << vprDEBUG_FLUSH; 1450 } 1451 } 1452 1453 vprDEBUG_CONT_END(vrjDBG_DRAW_MGR,debugLevel) << vprDEBUG_FLUSH; 1454 } 1455 1456 1486 << "chan " << ch << " -- " << std::hex << (void*) cur_chan 1487 << std::dec << " shared: FOV:" << (chan_mask & PFCHAN_FOV) 1488 << " Scene:" << (chan_mask & PFCHAN_SCENE) 1489 << " AppFunc:" << (chan_mask & PFCHAN_APPFUNC) 1490 << " SwapBuff:" << (chan_mask & PFCHAN_SWAPBUFFERS) 1491 << " SwapBuff-HW:" << (chan_mask & PFCHAN_SWAPBUFFERS_HW) 1492 << std::endl << vprDEBUG_FLUSH; 1493 } 1494 } 1495 1496 vprDEBUG_CONT_END(vrjDBG_DRAW_MGR, debugLevel) << vprDEBUG_FLUSH; 1497 } 1457 1498 1458 1499 // Config function called in draw proc after window is set up … … 1481 1522 } 1482 1523 1483 1484 1524 /* 1485 void PfAppFunc(pfChannel *chan, void* chandata)1525 void PfAppFunc(pfChannel* chan, void* chandata) 1486 1526 { 1487 1527 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) … … 1492 1532 1493 1533 pfChannel* master_chan = PfDrawManager::instance()->mMasterChan; 1494 if (master_chan == chan)1534 if ( master_chan == chan ) 1495 1535 { 1496 1536 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) 1497 1537 << "I am the master of the house:\n" << vprDEBUG_FLUSH; 1498 if (PfDrawManager::instance()->mPfAppCalled == false) // Haven't called it yet1538 if ( PfDrawManager::instance()->mPfAppCalled == false ) // Haven't called it yet 1499 1539 { 1500 1540 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) … … 1507 1547 else 1508 1548 { 1509 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) << "I am not master. I can't do anything.\n" << vprDEBUG_FLUSH; 1549 &n
