Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

vrj::PfDrawManager Class Reference

Concrete singleton class for API specific Draw Manager. More...

#include <PfDrawManager.h>

Inheritance diagram for vrj::PfDrawManager:

Inheritance graph
[legend]
Collaboration diagram for vrj::PfDrawManager:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual void sync ()
 Blocks until the end of the frame. More...

virtual void draw ()
pfScene * getRootWithSim ()
 Returns the Simulator SceneGraph so that PfBasicSimulator can add/update the Head and Wand. More...

virtual void setApp (App *_app)
 Sets the app the draw whould interact with. More...

virtual void initAPI ()
void initChanGroupAttribs (pfChannel *masterChan)
 Initialize the parameters of the master channel. More...

virtual void addDisplay (Display *disp)
 Callback when display is added to display manager. More...

virtual void removeDisplay (Display *disp)
 Callback when display is removed to display manager. More...

virtual void closeAPI ()
 Shutdown the drawing API. More...

virtual void updatePfProjections ()
 Update all the projections for the displays. More...

void debugDump (int debugLevel)
 Helper function that finds the pfDisp given a channel. More...

void debugDumpPfDisp (pfDisplay *pf_disp, int debugLevel)
virtual bool configCanHandle (jccl::ConfigElementPtr element)
 Can the handler handle the given element? More...


Protected Methods

virtual bool configAdd (jccl::ConfigElementPtr element)
 Adds the element to the configuration. More...

virtual bool configRemove (jccl::ConfigElementPtr element)
 Removes the element from the current configuration. More...

bool configDisplaySystem (jccl::ConfigElementPtr element)
 Sets up display system related attributes. More...

void callAppChanFuncs ()
 Call all the application channel callbacks. More...

void updatePfProjection (pfChannel *chan, Projection *proj)
void initPerformerGraph ()
 Helper function to create the base scene graph stuff. More...

void initAppGraph ()
 Helper that (re)loads the application's scene graph into the active scene(s). More...

void initPipes ()
 Init all the pipes that may need to be used. More...

pfPipe * getPfPipe (unsigned pipe_num)
 Gets a Performer pipe. More...

std::vector< int > getMonoFBConfig (vrj::Display *disp)
 Returns the needed mono frame buffer config. More...

std::vector< int > getStereoFBConfig (vrj::Display *disp)
 Returns the needed stereo frame buffer config. More...

void configFrameBuffer (vrj::Display *disp, std::vector< int > &attrs)
 Adds frame buffer configuration options to the given vector based on the given vrj::Display object's OpenGL frame buffer configuration. More...

 PfDrawManager ()
virtual ~PfDrawManager ()
 vprSingletonHeader (PfDrawManager)
Display helpers
Helpers for releasing a display and the associated cruft

void releaseDisplay (pfDisplay &disp)
void releaseViewport (pfDisplay &disp, pfViewport &vp)
pfPipeWindow * allocatePipeWin (unsigned pipeNum)
void releasePipeWin (pfPipeWindow *pipeWin, unsigned pipeNum)

Protected Attributes

unsigned int mNumPipes
 The number of Performer pipes. More...

PfAppmApp
 The User applications. More...

std::vector< pfDisplaymDisplays
 All Performer displays. More...

std::vector< pfChannel * > mSurfChannels
std::vector< pfChannel * > mSimChannels
 List of sim displays. More...

pfChannel * mSurfMasterChan
 Master channel. More...

pfChannel * mSimMasterChan
 Master channel for simulators. More...

std::vector< pfPipe * > mPipes
 Performer pipes we have opened. More...

std::vector< std::string > mPipeStrs
 The X-Strs of the pipes. More...

bool mPfHasForked
 Performer has forked it processes already. More...

std::vector< std::vector<
pfPipeWindow * > > 
mPipeWindows
 List of (available) pipe windows grouped by pipe num This is used as a repository of previously allocated but unused pipe windows We do this because Performer does not allow the deletion of pfPipeWindows. More...

Scene graph nodes
       mRoot
        |
     mSceneGroup -- mSceneRoot -- app scene
       /
 mRootWithSim   mHeadDCS
       \       /
       mSimTree
              |
              mWandDCS
 


pfScene * mRoot
 Root of performer tree to render. More...

pfGroup * mSceneRoot
 Root of scene to render (changes at run-time). More...

pfGroup * mSceneGroup
 The group node with only sceneRoot under it. More...

pfScene * mRootWithSim
 The root with the simulator group & the sceneRoot. More...


Friends

void PFconfigPWin (pfPipeWindow *pWin)
void PfDrawFunc (pfChannel *chan, void *chandata, bool left_eye, bool right_eye, bool stereo)
void PfAppFunc (pfChannel *chan, void *chandata)

Detailed Description

Concrete singleton class for API specific Draw Manager.

Responsible for all Performer rendering and windowing

Definition at line 67 of file PfDrawManager.h.


Constructor & Destructor Documentation

vrj::PfDrawManager::PfDrawManager   [inline, protected]
 

Definition at line 330 of file PfDrawManager.h.

00330                    :
00331       mApp(NULL),
00332       mSurfMasterChan(NULL),
00333       mSimMasterChan(NULL),
00334       mPfHasForked(false),
00335       mRoot(NULL),
00336       mSceneRoot(NULL),
00337       mSceneGroup(NULL),
00338       mRootWithSim(NULL)
00339    {;}

virtual vrj::PfDrawManager::~PfDrawManager   [inline, protected, virtual]
 

Definition at line 341 of file PfDrawManager.h.

00341 {}


Member Function Documentation

void vrj::PfDrawManager::sync   [virtual]
 

Blocks until the end of the frame.

Precondition:
none
Postcondition:
The frame has been drawn

Implements vrj::DrawManager.

Definition at line 145 of file PfDrawManager.cpp.

References vrjDBG_DRAW_MGR.

00146 {
00147    vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_VERB_LVL) << "vjPfDrawManager::sync\n" << vprDEBUG_FLUSH;
00148    pfSync();
00149 }

void vrj::PfDrawManager::draw   [virtual]
 

Precondition:
none
Postcondition:
Frame has been triggered to begin drawing

Implements vrj::DrawManager.

Definition at line 154 of file PfDrawManager.cpp.

References callAppChanFuncs, and updatePfProjections.

00155 {
00156    vprDEBUG(vprDBG_ALL,vprDBG_VERB_LVL) << "vjPfDrawManager::calling appChanFuncs\n" << vprDEBUG_FLUSH;
00157    callAppChanFuncs();
00158 
00159    updatePfProjections();
00160 
00161    vprDEBUG(vprDBG_ALL,vprDBG_VERB_LVL) << "vjPfDrawManager::draw\n" << vprDEBUG_FLUSH;
00162 
00163    pfFrame();
00164 }

pfScene* vrj::PfDrawManager::getRootWithSim   [inline]
 

Returns the Simulator SceneGraph so that PfBasicSimulator can add/update the Head and Wand.

Definition at line 134 of file PfDrawManager.h.

00135    { return mRootWithSim; }

void vrj::PfDrawManager::setApp App   _app [virtual]
 

Sets the app the draw whould interact with.

Precondition:
none
Postcondition:
self'.app = _app

Implements vrj::DrawManager.

Definition at line 191 of file PfDrawManager.cpp.

References initAppGraph, and mApp.

00192 {
00193    //vprASSERT(app != NULL);
00194    mApp = dynamic_cast<PfApp*>(_app);
00195    if(mPfHasForked)
00196       initAppGraph();         // If pf is already started, then intialize the app scene graph
00197 
00198 }

void vrj::PfDrawManager::initAPI   [virtual]
 

Configure process model Configure multi-pipe model Then call pfConfig to start the MP stuff Sets up channels and pWins.

Note:
Fork happens here

Implements vrj::DrawManager.

Definition at line 206 of file PfDrawManager.cpp.

References configDisplaySystem, initAppGraph, initPerformerGraph, initPipes, mApp, vrj::DrawManager::mDisplayManager, mNumPipes, mPfHasForked, mRoot, mRootWithSim, mSceneRoot, and vrjDBG_DRAW_MGR.

00207 {
00208    pfInit();
00209 
00210    // XXX: This call should really be triggered by a change in draw manager or something
00211    vprASSERT(mDisplayManager != NULL);
00212    configDisplaySystem(mDisplayManager->getDisplaySystemElement());    // Configure all the display system stuff
00213 
00214    mApp->preForkInit();
00215 
00216    vprDEBUG_BEGIN(vrjDBG_DRAW_MGR,vprDBG_STATE_LVL) << "vjPfDrawManager::initAPI: Entering." << std::endl << vprDEBUG_FLUSH;
00217 
00218    // Set params for Multi-pipe and Multiprocess
00219    pfMultipipe(mNumPipes);
00220 
00221    // If we are running in a cluster then we must run in single process mode.
00222    if(jccl::ConfigManager::instance()->isElementTypeInPendingList("cluster_manager") ||
00223       jccl::ConfigManager::instance()->isElementTypeInActiveList("cluster_manager"))
00224    {
00225       // Single process mode.
00226       pfMultiprocess(PFMP_APPCULLDRAW);
00227    }
00228    else
00229    {
00230       // Multiple process mode.
00231       pfMultiprocess(PFMP_APP_CULL_DRAW);
00232    }
00233 
00234 // We can not init head and wand model loaders since they are loaded in PfBasicSimInterface
00235 //   initLoaders();          // Must call before pfConfig
00236 
00237    // --- FORKS HERE --- //
00238    pfConfig();
00239    mPfHasForked = true;
00240 
00241    // Initialize the pipes that the system may need
00242    // If we don't do this, then pf automatically give each pipe a big black channel
00243    initPipes();
00244 
00245    initPerformerGraph();        // Create the other scene graph nodes
00246    if(mApp != NULL)
00247       initAppGraph();           // App was already set, but pf was not loaded.  So load graph now
00248 
00249 
00250    vprASSERT(mRoot != NULL && "We have a NULL root in PfDrawManager");
00251    vprASSERT(mRootWithSim != NULL && "We have a NULL sim root scene in PfDrawManager");
00252    vprASSERT(mSceneRoot != NULL && "We have a NULL root scene in PfDrawManager");
00253 
00254    //pfFrame();
00255 
00256    // Dump the state
00257 //   debugDump(vprDBG_CONFIG_LVL);
00258 
00259    vprDEBUG_END(vrjDBG_DRAW_MGR,vprDBG_STATE_LVL) << "vjPfDrawManager::initAPI: Exiting." << std::endl << vprDEBUG_FLUSH;
00260 }

void vrj::PfDrawManager::initChanGroupAttribs pfChannel *    masterChan
 

Initialize the parameters of the master channel.

Definition at line 713 of file PfDrawManager.cpp.

Referenced by addDisplay.

00714 {
00715    //masterChan->setNearFar(0.05, 10000.0f);      // XXX: Look here near far information
00716 
00717    vprASSERT(masterChan != NULL);
00718 
00719    /*  Original code for reference
00720     * masterChan->setShare(PFCHAN_NEARFAR | PFCHAN_EARTHSKY |
00721     *                    PFCHAN_STRESS | PFCHAN_LOD | PFCHAN_SWAPBUFFERS |
00722     *                    PFCHAN_APPFUNC | PFCHAN_SCENE | PFCHAN_CULLFUNC | PFCHAN_STATS_DRAWMODE );
00723     */
00724 
00725    //
00726    // Set the Channel attribs based on cur settings
00727    //
00728    unsigned cur_share = masterChan->getShare();          // Get current setting, and OR the new stuff on
00729    unsigned turn_on = ( PFCHAN_NEARFAR | PFCHAN_EARTHSKY |
00730                         PFCHAN_STRESS | PFCHAN_LOD | PFCHAN_SWAPBUFFERS |
00731                         PFCHAN_APPFUNC | PFCHAN_SCENE | PFCHAN_CULLFUNC |
00732                         PFCHAN_STATS_DRAWMODE);
00733    unsigned turn_off = (   PFCHAN_FOV |
00734                            PFCHAN_VIEW |
00735                            PFCHAN_VIEW_OFFSETS |
00736                            PFCHAN_DRAWFUNC );
00737 
00738    masterChan->setShare((cur_share | turn_on) &(~turn_off));
00739 
00740    //masterChan->setTravFunc(PFTRAV_APP, PfAppFunc);
00741    //masterChan->setShare(PFCHAN_NEARFAR | PFCHAN_EARTHSKY |
00742    //                     PFCHAN_STRESS | PFCHAN_SWAPBUFFERS |
00743    //                     PFCHAN_APPFUNC | PFCHAN_CULLFUNC );
00744 }

void vrj::PfDrawManager::addDisplay Display   disp [virtual]
 

Callback when display is added to display manager.

Precondition:
Must be in kernel controlling thread. Must have already initialized Performer.

Implements vrj::DrawManager.

Definition at line 324 of file PfDrawManager.cpp.

References allocatePipeWin, debugDump, getMonoFBConfig, getPfPipe, getStereoFBConfig, initChanGroupAttribs, mDisplays, mPfHasForked, mRoot, mRootWithSim, mSimChannels, mSimMasterChan, mSurfChannels, mSurfMasterChan, PFconfigPWin, vrj::PfDrawFuncMonoBackbuffer, vrj::PfDrawFuncStereoLeft, vrj::PfDrawFuncStereoRight, and vrjDBG_DRAW_MGR.

00325 {
00326    vprASSERT(disp != NULL);    // Can't add a null display
00327    vprASSERT((true == mPfHasForked) && "Trying to add display when performer has not been initialized");
00328 
00329    // Get frame buffer config
00330    std::vector<int> stereo_fb_config = getStereoFBConfig(disp);
00331    std::vector<int> mono_fb_config = getMonoFBConfig(disp);
00332 
00333    // ouput debug info about the frame buffer config recieved
00334 #ifdef VJ_DEBUG
00335    vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_VERB_LVL)
00336       << "vrj::PfDrawManager::addDisplay(): Got Stereo FB config\n"
00337       << vprDEBUG_FLUSH;
00338    for ( unsigned int i = 0; i < stereo_fb_config.size(); ++i )
00339    {
00340       vprDEBUG_CONT(vrjDBG_DRAW_MGR,vprDBG_VERB_LVL)
00341          << "  " << stereo_fb_config[i] << vprDEBUG_FLUSH;
00342    }
00343    vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_VERB_LVL)
00344       << "\nvrj::PfDrawManager::addDisplay(): Got Mono FB config\n"
00345       << vprDEBUG_FLUSH;
00346    for ( unsigned int j = 0 ; j < mono_fb_config.size(); ++j )
00347    {
00348       vprDEBUG_CONT(vrjDBG_DRAW_MGR,vprDBG_VERB_LVL)
00349          << "  " << mono_fb_config[j] << std::endl << vprDEBUG_FLUSH;
00350    }
00351    vprDEBUG_CONT(vrjDBG_DRAW_MGR,vprDBG_VERB_LVL) << std::endl << vprDEBUG_FLUSH;
00352 #endif
00353 
00354    //  For the display
00355    //     -Create a pWin for it
00356    //     - For each viewport
00357    //        - Create viewport
00358    //        - Create channels for the viewports
00359    vprDEBUG_OutputGuard(vrjDBG_DRAW_MGR, vprDBG_STATE_LVL,
00360                               std::string("vjPfDrawManager: ---- Opening new Display --------\n"),
00361                               std::string("vjPfDrawManager: ---- Display Open (done) --------\n"));
00362 
00363 
00364 
00365    pfDisplay pf_disp;            // The pfDisplay to use
00366    pf_disp.disp = disp;
00367 
00368    vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "\tDisplay is:" << (void*)(disp) << std::endl << vprDEBUG_FLUSH;
00369    vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "\tPfDrawManager::add Display: Got Display:\n" << (*disp) << vprDEBUG_FLUSH;
00370 
00371    int xo, yo, xs, ys;
00372    pfPipe* pipe = getPfPipe(disp->getPipe());      // Get the pipe
00373 
00374    // Make sure we have a good pipe.  If not, there isn't anything we can do
00375    // to recover.
00376    if ( NULL == pipe )
00377    {
00378       vprASSERT(NULL != pipe);
00379       return;
00380    }
00381 
00382    // --- SETUP PWIN --- //
00383    pf_disp.pWin = allocatePipeWin(disp->getPipe());     //  new pfPipeWindow(pipe);
00384    vprASSERT(NULL != pf_disp.pWin);
00385 
00386    disp->getOriginAndSize(xo, yo, xs, ys);
00387    pf_disp.pWin->setOriginSize(xo, yo, xs, ys);
00388 
00389    // Setup window border
00390    if (disp->shouldDrawBorder())
00391       pf_disp.pWin->setName(disp->getName().c_str()); // Give the window a name
00392    else
00393       pf_disp.pWin->setMode(PFWIN_NOBORDER, 1);          // Get rid of that border
00394 
00395    // Setup Frame Buffer config
00396    if (disp->isStereoRequested())                     // If we need stereo
00397    {
00398       vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "vjPfDrawManager::addDisplay: Configuring stereo window attribs.\n" << vprDEBUG_FLUSH;
00399       pf_disp.pWin->setFBConfigAttrs(&(stereo_fb_config[0]));     // Configure framebuffer for stereo
00400    }
00401    else
00402    {
00403       vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "vjPfDrawManager::addDisplay: Configuring mono window attribs.\n" << vprDEBUG_FLUSH;
00404       pf_disp.pWin->setFBConfigAttrs(&(mono_fb_config[0]));       // Configure a "norm" window
00405    }
00406 
00407    // -- Set config info -- //
00408    pf_disp.pWin->setConfigFunc(PFconfigPWin); // Set config function
00409    pf_disp.pWin->config();                      // Next pfFrame, config Func will be called
00410 
00411    // --- SETUP VIEWPORTS --- //
00412    // for(each viewport)
00413    //   - Allocate channels
00414    //   - Set draw functions
00415    //   - Setup master chans
00416    Viewport* viewport = NULL;
00417    unsigned num_vps = disp->getNumViewports();
00418 
00419    vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL) << "   Num viewports: " << num_vps << std::endl << vprDEBUG_FLUSH;
00420    for(unsigned vp_num=0; vp_num < num_vps; vp_num++)
00421    {
00422       viewport = disp->getViewport(vp_num);
00423 
00424       if(viewport->isActive())      // is viewport active
00425       {
00426          //Viewport::View view = viewport->getView();
00427          pfViewport pf_viewport;                         // The viewport to build up
00428          pf_viewport.viewport = viewport;
00429          float vp_ox, vp_oy, vp_sx, vp_sy;
00430 
00431          // Get channel info
00432          // Primary channel - (Left in stereo)
00433          viewport->getOriginAndSize(vp_ox, vp_oy, vp_sx, vp_sy);
00434          pf_viewport.chans[pfViewport::PRIMARY] = new pfChannel(pipe);
00435          pf_viewport.chans[pfViewport::PRIMARY]->setViewport(vp_ox, vp_ox+vp_sx, vp_oy, vp_oy+vp_sy);
00436          pf_disp.pWin->addChan(pf_viewport.chans[pfViewport::PRIMARY]);
00437 
00438          // Secondary channel - (Right in stereo)
00439          if(disp->isStereoRequested())
00440          {
00441             pf_viewport.chans[pfViewport::SECONDARY] = new pfChannel(pipe);
00442             pf_viewport.chans[pfViewport::SECONDARY]->setViewport(vp_ox, vp_ox+vp_sx, vp_oy, vp_oy+vp_sy);
00443             pf_disp.pWin->addChan(pf_viewport.chans[pfViewport::SECONDARY]);
00444          }
00445 
00446          // Set draw function
00447          if(disp->isStereoRequested())
00448          {
00449             pf_viewport.chans[pfViewport::PRIMARY]->setTravFunc(PFTRAV_DRAW, PfDrawFuncStereoLeft);
00450             pf_viewport.chans[pfViewport::SECONDARY]->setTravFunc(PFTRAV_DRAW, PfDrawFuncStereoRight);
00451          }
00452          else
00453          {
00454             pf_viewport.chans[pfViewport::PRIMARY]->setTravFunc(PFTRAV_DRAW, PfDrawFuncMonoBackbuffer);
00455          }
00456 
00457          // if surface ==> Setup surface channels
00458          if (viewport->isSurface())
00459          {
00460             vprASSERT(pf_viewport.chans[pfViewport::PRIMARY] != NULL);
00461 
00462             // Primary
00463             if(NULL == mSurfMasterChan)      // If NULL, then add us as the new one
00464             {
00465                mSurfMasterChan = pf_viewport.chans[pfViewport::PRIMARY];
00466                mSurfMasterChan->setScene(mRoot);
00467                initChanGroupAttribs(mSurfMasterChan);
00468                mSurfChannels.push_back(mSurfMasterChan);
00469             }
00470             else
00471             {
00472                mSurfChannels.push_back(pf_viewport.chans[pfViewport::PRIMARY]);
00473                mSurfMasterChan->attach(pf_viewport.chans[pfViewport::PRIMARY]);
00474             }
00475 
00476             // Secondary
00477             if(NULL != pf_viewport.chans[pfViewport::SECONDARY])
00478             {
00479                mSurfChannels.push_back(pf_viewport.chans[pfViewport::SECONDARY]);
00480                mSurfMasterChan->attach(pf_viewport.chans[pfViewport::SECONDARY]);
00481             }
00482 
00483          }
00484          // if sim ==> setup sim channels
00485          else if(viewport->isSimulator())
00486          {
00487             // -- Finish Simulator setup
00488             jccl::ConfigElementPtr vp_element = viewport->getConfigElement();
00489 
00490             SimViewport* sim_vp(NULL);
00491             sim_vp = dynamic_cast<SimViewport*>(viewport);
00492             vprASSERT(NULL != sim_vp);
00493 
00494             sim_vp->setDrawSimInterface(NULL);
00495 
00496             // Create the simulator stuff
00497             vprASSERT(1 == vp_element->getNum("simulator_plugin") && "You must supply a simulator plugin.");
00498 
00499             jccl::ConfigElementPtr sim_element =
00500                vp_element->getProperty<jccl::ConfigElementPtr>("simulator_plugin");
00501 
00502             vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL)
00503                << "PfDrawManager::addDisplay() creating simulator of type '"
00504                << sim_element->getID() << "'\n" << vprDEBUG_FLUSH;
00505 
00506             DrawSimInterface* new_sim_i =
00507                PfSimInterfaceFactory::instance()->createObject(sim_element->getID());
00508 
00509             // XXX: Change this to an error once the new simulator loading code is
00510             // more robust.  -PH (4/13/2003)
00511             vprASSERT(NULL != new_sim_i && "Failed to create draw simulator");
00512             sim_vp->setDrawSimInterface(new_sim_i);
00513             new_sim_i->initialize(sim_vp);
00514             new_sim_i->config(sim_element);
00515 
00516 
00517             vprASSERT(pf_viewport.chans[pfViewport::PRIMARY] != NULL);
00518 
00519             // Primary
00520             if(NULL == mSimMasterChan)        // If NULL, then make us the master
00521             {
00522                mSimMasterChan = pf_viewport.chans[pfViewport::PRIMARY];
00523                mSimMasterChan->setScene(mRootWithSim);       // Set the shared "normal" scene
00524                initChanGroupAttribs(mSimMasterChan);       // Setup the channel group attribs
00525                mSimChannels.push_back(mSimMasterChan);
00526             }
00527             else
00528             {
00529                mSimChannels.push_back(pf_viewport.chans[pfViewport::PRIMARY]);
00530                mSimMasterChan->attach(pf_viewport.chans[pfViewport::PRIMARY]);
00531             }
00532 
00533             // Secondary
00534             if(NULL != pf_viewport.chans[pfViewport::SECONDARY])
00535             {
00536                mSimChannels.push_back(pf_viewport.chans[pfViewport::SECONDARY]);
00537                mSimMasterChan->attach(pf_viewport.chans[pfViewport::SECONDARY]);
00538             }
00539          }
00540 
00541          // Add viewport to the display list
00542          pf_disp.viewports.push_back(pf_viewport);
00543 
00544       }  // is viewport active
00545    }     // for each viewport
00546 
00547    // -- Add new pfDisp to disp Vector -- //
00548    mDisplays.push_back(pf_disp);
00549 
00550    // Dump the state
00551    vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL)
00552       << "Reconfiged the pfDrawManager.\n" << vprDEBUG_FLUSH;
00553    //vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL) << (*this) << vprDEBUG_FLUSH;
00554    debugDump(vprDBG_CONFIG_LVL);
00555 }

void vrj::PfDrawManager::removeDisplay Display   disp [virtual]
 

Callback when display is removed to display manager.

Precondition:
disp must be a valid display that we have.
Postcondition:
Window for disp is removed from the draw manager and child pipes.

Implements vrj::DrawManager.

Definition at line 564 of file PfDrawManager.cpp.

References mDisplays, releaseDisplay, and vrjDBG_DRAW_MGR.

00565 {
00566    // Find the pfDisplay
00567 #ifdef VPR_OS_Win32
00568    // Visual C++ does not have std::compose1(), so we have to do this the
00569    // tedious, non-template-coolness way.
00570    std::vector<pfDisplay>::iterator disp_i;
00571    for ( disp_i = mDisplays.begin(); disp_i != mDisplays.end(); ++disp_i )
00572    {
00573       if ( disp == (*disp_i).disp )
00574       {
00575          break;
00576       }
00577    }
00578 #else
00579    std::vector<pfDisplay>::iterator disp_i = std::find_if(mDisplays.begin(), mDisplays.end(),
00580                          std::compose1( std::bind2nd( std::equal_to<Display*>(),disp),
00581                                         pfDisplay_disp()) );
00582 #endif
00583 
00584 
00585    if(mDisplays.end() == disp_i)
00586    {
00587       vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) << "ERROR: PfDrawManager::removeDisplay: Tried to remove a non-existant display\n" << vprDEBUG_FLUSH;
00588       return;
00589    }
00590 
00591 
00592    // Release the pfDisplay
00593    releaseDisplay(*disp_i);
00594 
00595    // Remove display from the list
00596    mDisplays.erase(disp_i);
00597 }

void vrj::PfDrawManager::closeAPI   [virtual]
 

Shutdown the drawing API.

Implements vrj::DrawManager.

Definition at line 896 of file PfDrawManager.cpp.

00897 {
00898    pfExit();
00899 }

void vrj::PfDrawManager::updatePfProjections   [virtual]
 

Update all the projections for the displays.

Postcondition:
All windows have the projections correctly set.

Definition at line 902 of file PfDrawManager.cpp.

References mApp, vrj::DrawManager::mDisplayManager, mDisplays, updatePfProjection, and vrjDBG_DRAW_MGR.

Referenced by draw.

00903 {
00904    vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_VERB_LVL) << "vjPfDrawManager::updatePfProjections: Entering." << std::endl << vprDEBUG_FLUSH;
00905 
00906    // Update display projections
00907    float scale_factor = mApp->getDrawScaleFactor();
00908    mDisplayManager->updateProjections(scale_factor);
00909 
00910    // --- Update the channel projections --- //
00911    //for(each pfDisp)
00912    //   for(each viewport)
00913    //       update Performer specific stuff.
00914    for (unsigned disp_id=0;disp_id<mDisplays.size();disp_id++)    // each display
00915    {
00916       pfDisplay* cur_disp = &(mDisplays[disp_id]);
00917 
00918       vprASSERT(cur_disp->disp != NULL);
00919       for(unsigned vp=0;vp<cur_disp->viewports.size();vp++)       // each viewport
00920       {
00921          pfViewport* pf_vp = &(cur_disp->viewports[vp]);
00922          vprASSERT(pf_vp != NULL);
00923          vprASSERT(pf_vp->viewport != NULL);
00924 
00925          /*
00926          SurfaceViewport* surf_vp(NULL);
00927          */
00928 
00929          Viewport* cur_vp(pf_vp->viewport);
00930          Viewport::View view;
00931 
00932          // --- All viewports --- //
00933          //surf_vp = dynamic_cast<SurfaceViewport*>(pf_vp->viewport);
00934          //vprASSERT(surf_vp != NULL && "Could not cast supposedly surface display to SurfaceDisplay.");
00935          view = cur_vp->getView();
00936 
00937          if(Viewport::LEFT_EYE == view)
00938          {
00939             updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], cur_vp->getLeftProj());
00940          }
00941          else if(Viewport::RIGHT_EYE == view)
00942          {
00943             updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], cur_vp->getRightProj());
00944          }
00945          else if(Viewport::STEREO == view)
00946          {
00947             updatePfProjection(pf_vp->chans[pfViewport::PRIMARY], cur_vp->getLeftProj());
00948             updatePfProjection(pf_vp->chans[pfViewport::SECONDARY], cur_vp->getRightProj());
00949          }
00950          else
00951          {
00952             vprASSERT(false && "vjPfDrawManager::updateProjections(): We don't have a valid display type, don't know what to do");
00953          }
00954 
00955          // Sim viewport
00956          if(cur_vp->isSimulator())
00957          {
00958             SimViewport*      sim_vp(NULL);
00959             PfSimInterface*   draw_sim_i(NULL);
00960 
00961             sim_vp = dynamic_cast<SimViewport*>(pf_vp->viewport);
00962             vprASSERT(sim_vp != NULL && "Could not cast supposed simulator display to SimDisplay.");
00963 
00964             draw_sim_i = dynamic_cast<PfSimInterface*>(sim_vp->getDrawSimInterface());
00965             vprASSERT(draw_sim_i != NULL && "Could not cast supposed simulator interface to PfSimInterface.");
00966 
00967             draw_sim_i->updateSimulatorSceneGraph();
00968          }
00969 
00970       }
00971    }
00972 }

void vrj::PfDrawManager::debugDump int    debugLevel
 

Helper function that finds the pfDisp given a channel.

This function just loops through all the entries in the disps variable, looking for one that contains the channel. When it is found, it is returned.

Note:
The "cool" STL functor search didn't work for some reason.

Definition at line 1067 of file PfDrawManager.cpp.

References debugDumpPfDisp, mApp, mDisplays, mRoot, mRootWithSim, and vrjDBG_DRAW_MGR.

Referenced by addDisplay.

01068 {
01069    vprDEBUG_BEGIN(vrjDBG_DRAW_MGR,debugLevel) << "-- DEBUG DUMP --------- " << clrOutNORM(clrCYAN,"vjPfDrawManager:") << (void*)this << " ------------" << std::endl << vprDEBUG_FLUSH;
01070    vprDEBUG_NEXT(vrjDBG_DRAW_MGR,debugLevel)       << "app:" << (void*)mApp << std::endl << vprDEBUG_FLUSH;
01071    vprDEBUG_NEXT(vrjDBG_DRAW_MGR,debugLevel)       << "scene:" << (void*)mRoot << std::endl << vprDEBUG_FLUSH;
01072    vprDEBUG_NEXT(vrjDBG_DRAW_MGR,debugLevel)       << "sim scene:" << (void*)mRootWithSim << std::endl << vprDEBUG_FLUSH;
01073    vprDEBUG_NEXT(vrjDBG_DRAW_MGR,debugLevel)       << "Disps:" << mDisplays.size() << std::endl << vprDEBUG_FLUSH;
01074    for (std::vector<pfDisplay>::iterator i = mDisplays.begin(); i != mDisplays.end(); i++)
01075    {
01076       debugDumpPfDisp(&(*i),debugLevel);
01077    }
01078 
01079    vprDEBUG_END(vrjDBG_DRAW_MGR,debugLevel) << "-------- Dump end ----\n" << vprDEBUG_FLUSH;
01080 }

void vrj::PfDrawManager::debugDumpPfDisp pfDisplay   pf_disp,
int    debugLevel
 

Definition at line 1083 of file PfDrawManager.cpp.

References vrjDBG_DRAW_MGR.

Referenced by debugDump.

01084 {
01085    vprDEBUG_BEGIN(vrjDBG_DRAW_MGR,debugLevel) << "Display:" << (void*)(pf_disp->disp) << std::endl << vprDEBUG_FLUSH;
01086    vprDEBUG_NEXT(vrjDBG_DRAW_MGR,debugLevel)  << "pWin:" << (void*)(pf_disp->pWin) << std::endl << vprDEBUG_FLUSH;
01087    vprDEBUG_NEXT(vrjDBG_DRAW_MGR,debugLevel)  << "vis id:" << std::hex << pf_disp->pWin->getFBConfigId() << std::dec << std::endl << vprDEBUG_FLUSH;
01088 
01089    for(unsigned vp=0; vp<pf_disp->viewports.size(); ++vp)
01090    {
01091       vprASSERT((pf_disp->viewports[vp].viewport != NULL) && "NULL viewport in pf_disp. Check if it was ever set.");
01092 
01093       vprDEBUG_NEXT(vrjDBG_DRAW_MGR,debugLevel) << "Viewport: " << vp << vprDEBUG_FLUSH;
01094       vprDEBUG_NEXT(vrjDBG_DRAW_MGR,debugLevel) << "      vp: " << *(pf_disp->viewports[vp].viewport) << vprDEBUG_FLUSH;
01095 
01096       for(int ch=0;ch<2;ch++)
01097       {
01098          pfChannel* cur_chan = pf_disp->viewports[vp].chans[ch];
01099          unsigned chan_mask(0);
01100          if(cur_chan != NULL)
01101             chan_mask = cur_chan->getShare();
01102          vprDEBUG_NEXT(vrjDBG_DRAW_MGR,debugLevel)
01103               << "chan:" << ch << " -- " << (void*)cur_chan
01104               << "  shared: FOV:" << (chan_mask & PFCHAN_FOV)
01105               << " Scene:" << (chan_mask & PFCHAN_SCENE)
01106               << " AppFunc:" << (chan_mask & PFCHAN_APPFUNC)
01107               << " SwapBuff:" << (chan_mask & PFCHAN_SWAPBUFFERS)
01108               << " SwapBuff-HW:" << (chan_mask & PFCHAN_SWAPBUFFERS_HW)
01109               << std::endl << vprDEBUG_FLUSH;
01110       }
01111    }
01112 
01113    vprDEBUG_CONT_END(vrjDBG_DRAW_MGR,debugLevel) << vprDEBUG_FLUSH;
01114 }

virtual bool vrj::PfDrawManager::configCanHandle jccl::ConfigElementPtr    element [inline, virtual]
 

Can the handler handle the given element?

Returns:
true - Can handle it false - Can't handle it

Definition at line 186 of file PfDrawManager.h.

00187    {
00188       boost::ignore_unused_variable_warning(element);
00189       return false;
00190    }

virtual bool vrj::PfDrawManager::configAdd jccl::ConfigElementPtr    element [inline, protected, virtual]
 

Adds the element to the configuration.

Precondition:
configCanHandle(element) == true.
Returns:
success.

Definition at line 198 of file PfDrawManager.h.

00199    {
00200       boost::ignore_unused_variable_warning(element);
00201       vprDEBUG(vprDBG_ALL,vprDBG_CRITICAL_LVL)
00202          << "vrj::PfDrawManager::configAdd: configAdd is not supported.\n"
00203          << vprDEBUG_FLUSH;
00204       return false;
00205    }

virtual bool vrj::PfDrawManager::configRemove jccl::ConfigElementPtr    element [inline, protected, virtual]
 

Removes the element from the current configuration.

Precondition:
configCanHandle(element) == true.
Returns:
success.

Definition at line 212 of file PfDrawManager.h.

00213    {
00214       boost::ignore_unused_variable_warning(element);
00215       vprDEBUG(vprDBG_ALL,vprDBG_CRITICAL_LVL)
00216          << "vrj::PfDrawManager::configRemove: configRemove is not supported.\n"
00217          << vprDEBUG_FLUSH;
00218       return false;
00219    }

bool vrj::PfDrawManager::configDisplaySystem jccl::ConfigElementPtr    element [protected]
 

Sets up display system related attributes.

Precondition:
element is a config element of the "dispaySystem" type.
Note:
MUST be called before initDrawing.
This must be called by the draw manager because the element must be gotten from the draw manager.

Definition at line 97 of file PfDrawManager.cpp.

References mNumPipes, mPipeStrs, and vrjDBG_DRAW_MGR.

Referenced by initAPI.

00098 {
00099    vprASSERT(element.get() != NULL);
00100    vprASSERT(element->getID() == std::string("display_system"));
00101 
00102    // ---- SETUP PipeStr's ---- //
00103    vprDEBUG_BEGIN(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL)
00104       << "------------- PfDrawManager::config ----------------" << std::endl
00105       << vprDEBUG_FLUSH;
00106    mNumPipes = element->getProperty<unsigned int>("number_of_pipes");
00107 
00108    vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "NumPipes: " << mNumPipes
00109                                             << std::endl << vprDEBUG_FLUSH;
00110 
00111    // Make sure that the user has specified a valid number of pipes in the
00112    // configuration. This becomes an issue normally since the default number of
00113    // pipes when creating a new display_system element is 0. It needs to be this
00114    // because we can not fill in the list of pipes with default values.
00115    if(mNumPipes < 1)
00116    {
00117       mNumPipes = 1;
00118    }
00119    
00120    for (unsigned int i=0;i<mNumPipes;i++)
00121    {
00122       std::string cur_disp_name = "-1";
00123       
00124       // NOTE: ConfigElements return the default value for a property if a value is
00125       //       not present. So if a pipe string is not specified for this pipe then
00126       //       it gets the default value of "-1".
00127       mPipeStrs.push_back(element->getProperty<std::string>("x11_pipes", i));
00128 
00129       if(mPipeStrs[i] == cur_disp_name)    // Use display env
00130       {
00131          const char env_var[] = "DISPLAY";
00132          char* display_env = getenv(env_var);
00133          if ( display_env != NULL )
00134          {
00135             mPipeStrs[i] = display_env;
00136          }
00137       }
00138       vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "Pipe:" << i << ": "
00139                                                << mPipeStrs[i] << std::endl
00140                                                << vprDEBUG_FLUSH;
00141    }
00142    return true;
00143 }

void vrj::PfDrawManager::callAppChanFuncs   [protected]
 

Call all the application channel callbacks.

Definition at line 167 of file PfDrawManager.cpp.

References mApp, and mDisplays.

Referenced by draw.

00168 {
00169    // for(each display)
00170    //    for(each viewport)
00171    //       for(each channel)
00172    for(unsigned int dispIndex=0;dispIndex<mDisplays.size();dispIndex++)
00173    {
00174       for(unsigned vp=0;vp<mDisplays[dispIndex].viewports.size();vp++)
00175       {
00176          for(unsigned ch=0;ch<2;ch++)
00177          {
00178             if(mDisplays[dispIndex].viewports[vp].chans[ch] != NULL)
00179                mApp->appChanFunc(mDisplays[dispIndex].viewports[vp].chans[ch]);
00180          }
00181       }
00182    }
00183 }

void vrj::PfDrawManager::updatePfProjection pfChannel *    chan,
Projection   proj
[protected]
 

Postcondition:
chan has its view matrix set to the Performer. Equivalent of proj's projection data.

Definition at line 978 of file PfDrawManager.cpp.

References vrjDBG_DRAW_MGR.

Referenced by updatePfProjections.

00979 {
00980 
00981    vprDEBUG_BEGIN(vrjDBG_DRAW_MGR,vprDBG_HVERB_LVL) << "vjPfDrawManager::updatePfProjection: Entering. viewMat:\n"
00982                     << proj->getViewMatrix() << std::endl << vprDEBUG_FLUSH;
00983 
00984 
00985    pfMatrix pfViewMat;
00986    pfViewMat.set(const_cast<float*>(proj->getViewMatrix().mData));  // Hmm...
00987 
00988       // Basically, Performer does a Rotate of 90 around X
00989       // first thing in modelview.  So, we have to undo that, put
00990       // our OGL matrix on, and then redo the Performer thing.
00991       // The matrix inversion is because Performer specifies
00992       // Their viewing params in modelling coords instead
00993       // of camera coords.
00994    pfViewMat.invertAff(pfViewMat);
00995    pfViewMat.preRot(-90, 1, 0, 0, pfViewMat);
00996    pfViewMat.postRot(pfViewMat, 90, 1, 0, 0);
00997 
00998    chan->setViewMat(pfViewMat);
00999 
01000    /*
01001    if(!simulator)
01002    {
01003    */
01004       vrj::Frustum frust(proj->getFrustum());
01005       chan->setAutoAspect(PFFRUST_CALC_NONE);         // No auto aspect
01006       chan->setNearFar(frust[Frustum::VJ_NEAR], frust[Frustum::VJ_FAR]);
01007       chan->makePersp(frust[Frustum::VJ_LEFT], frust[Frustum::VJ_RIGHT],
01008                       frust[Frustum::VJ_BOTTOM], frust[Frustum::VJ_TOP]);
01009    /*
01010    }
01011    else
01012    {
01013       CameraProjection* cam_proj = dynamic_cast<CameraProjection*>(proj);
01014       vprASSERT(cam_proj != NULL && "Trying to use non-camera projection for simulator");
01015       chan->setAutoAspect(PFFRUST_CALC_HORIZ);
01016       chan->setNearFar(proj->getFrustum()[Frustum::VJ_NEAR],
01017                        proj->getFrustum()[Frustum::VJ_FAR]);
01018       chan->setFOV(0.0f, cam_proj->mVertFOV);
01019    }
01020    */
01021 
01022    vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_HEX_LVL)
01023       << "Frustum: l:" << proj->getFrustum()[Frustum::VJ_LEFT]
01024       << "   r: " << proj->getFrustum()[Frustum::VJ_RIGHT]
01025       << "   b: " << proj->getFrustum()[Frustum::VJ_BOTTOM]
01026       << "   t: " << proj->getFrustum()[Frustum::VJ_TOP] << std::endl
01027       << vprDEBUG_FLUSH;
01028 
01029    vprDEBUG_END(vrjDBG_DRAW_MGR,vprDBG_HVERB_LVL)
01030       << "vjPfDrawManager::updatePfProjection: Exiting.\n" << vprDEBUG_FLUSH;
01031 }

void vrj::PfDrawManager::initPerformerGraph   [protected]
 

Helper function to create the base scene graph stuff.

Definition at line 872 of file PfDrawManager.cpp.

References mRoot, mRootWithSim, and mSceneGroup.

Referenced by initAPI.

00873 {
00874    mRoot = new pfScene;
00875    mRootWithSim = new pfScene;
00876 
00877    mSceneGroup = new pfGroup;                // (Placeholder until app loads theirs)
00878    mRoot->addChild(mSceneGroup);        // Create the base scene without sim
00879    mRootWithSim->addChild(mSceneGroup);      // Create base scene with sim
00880 }

void vrj::PfDrawManager::initAppGraph   [protected]
 

Helper that (re)loads the application's scene graph into the active scene(s).

Definition at line 886 of file PfDrawManager.cpp.

References mApp, mSceneGroup, and mSceneRoot.

Referenced by initAPI, and setApp.

00887 {
00888    mApp->initScene();
00889    if(mSceneRoot != NULL)
00890       mSceneGroup->removeChild(mSceneRoot);
00891 
00892    mSceneRoot = mApp->getScene();
00893    mSceneGroup->addChild(mSceneRoot);
00894 }

void vrj::PfDrawManager::initPipes   [protected]
 

Init all the pipes that may need to be used.

Definition at line 296 of file PfDrawManager.cpp.

References allocatePipeWin, mNumPipes, mPipes, mPipeStrs, vrj::PfPipeSwapFunc, and vrjDBG_DRAW_MGR.

Referenced by initAPI.

00297 {
00298    mPipes.resize(mNumPipes, NULL);     // Resize the vector
00299 
00300    for(unsigned pipe_num=0; pipe_num<mNumPipes; pipe_num++)
00301    {
00302       vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "vjPfDrawManager::initPipes: Opening Pipe." << std::endl << vprDEBUG_FLUSH;
00303       vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_CONFIG_LVL) << "\tpipe:" << pipe_num << ": " << mPipeStrs[pipe_num] << std::endl << vprDEBUG_FLUSH;
00304 
00305       mPipes[pipe_num] = pfGetPipe(pipe_num);
00306       mPipes[pipe_num]->setWSConnectionName(mPipeStrs[pipe_num].c_str());
00307       mPipes[pipe_num]->setScreen(pipe_num);
00308 
00309       pfPipeWindow* pw = allocatePipeWin(pipe_num);   // new pfPipeWindow(mPipes[pipe_num]);
00310       pw->setOriginSize(0,0,1,1);
00311 
00312       // XXX: Set the swap func
00313       mPipes[pipe_num]->setSwapFunc( PfPipeSwapFunc );      // Set to the given swap func
00314    }
00315 }

pfPipe * vrj::PfDrawManager::getPfPipe unsigned    pipe_num [protected]
 

Gets a Performer pipe.

Precondition:
pipe_num < mNumPipes Fork must have happend

Definition at line 268 of file PfDrawManager.cpp.

References mNumPipes, mPfHasForked, and mPipes.

Referenced by addDisplay, and allocatePipeWin.

00269 {
00270    vprASSERT((mPfHasForked) && "Tried to get pipe before forking happened");
00271    vprASSERT((pipe_num < mNumPipes) && "Tried to request out of bounds pipe");
00272    vprASSERT((pipe_num < mPipes.size()) && "Tried to get out of range pipe");
00273    vprASSERT((NULL != mPipes[pipe_num]) && "Have NULL pipe");
00274 
00275    // Print an error message if an invalid pipe was requested.  This will
00276    // probably only happen when a configuration is broken.
00277    if ( pipe_num >= mNumPipes || pipe_num >= mPipes.size() ||
00278         NULL == mPipes[pipe_num] )
00279    {
00280       vprDEBUG(vprDBG_ERROR, vprDBG_CRITICAL_LVL)
00281          << clrOutNORM(clrRED, "ERROR:")
00282          << " Invalid pipe number (" << pipe_num << ") requested.  "
00283          << "Check display system configuration\n" << vprDEBUG_FLUSH;
00284       return NULL;
00285    }
00286    else
00287    {
00288       // Return the actual pipe
00289       return mPipes[pipe_num];
00290    }
00291 }

void vrj::PfDrawManager::releaseDisplay pfDisplay   disp [protected]
 

Definition at line 599 of file PfDrawManager.cpp.

References releasePipeWin, and releaseViewport.

Referenced by removeDisplay.

00600 {
00601    // Release all viewports
00602    for(std::vector<pfViewport>::iterator i=disp.viewports.begin(); i != disp.viewports.end(); i++)
00603    {
00604       releaseViewport(disp, *i);
00605    }
00606 
00607    // Release the pipe window
00608    releasePipeWin(disp.pWin, disp.disp->getPipe());
00609 }

void vrj::PfDrawManager::releaseViewport pfDisplay   disp,
pfViewport   vp
[protected]
 

Definition at line 612 of file PfDrawManager.cpp.

References mSimChannels, mSimMasterChan, mSurfChannels, mSurfMasterChan, and vrjDBG_DRAW_MGR.

Referenced by releaseDisplay.

00613 {
00614    std::vector<pfChannel*>::iterator chan_i;
00615 
00616    // Release the channel stuff
00617    for(int i=0;i<2;i++)
00618    {
00619       pfChannel* chan = vp.chans[i];
00620 
00621       // if we have a channel to delete
00622       if(chan != NULL)
00623       {
00624          if(vp.viewport->isSurface())         // SURFACE display
00625          {
00626             // Remove the channel from the list of channels
00627             chan_i = std::find(mSurfChannels.begin(), mSurfChannels.end(), chan);
00628             if(chan_i == mSurfChannels.end())
00629             {
00630                vprASSERT(false && "Trying to remove a non-existant channel");
00631                vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) << "Trying to remove a non-existant pfChannel\n" << vprDEBUG_FLUSH;
00632             }
00633 
00634             // Check if we were the master
00635             if(chan == mSurfMasterChan)
00636             {
00637                mSurfMasterChan = NULL;                      // Get new master channel
00638                if(mSurfChannels.size() > 0)
00639                   mSurfMasterChan = mSurfChannels[0];
00640             }
00641 
00642             if(mSurfMasterChan != NULL)                  // Dettach from the channel
00643                chan->detach(mSurfMasterChan);
00644          }
00645          else if(vp.viewport->isSimulator())    // SIMULATOR display
00646          {
00647             // Remove the channel from the list of channels
00648             chan_i = std::find(mSimChannels.begin(), mSimChannels.end(), chan);
00649             if(chan_i == mSimChannels.end())
00650             {
00651                vprASSERT(false && "Trying to remove a non-existant channel");
00652                vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CRITICAL_LVL) << "Trying to remove a non-existant pfChannel";
00653             }
00654 
00655             // Check if we were the master
00656             if(chan == mSimMasterChan)
00657             {
00658                mSimMasterChan = NULL;                      // Get new master channel
00659                if(mSimChannels.size() > 0)
00660                   mSimMasterChan = mSimChannels[0];
00661             }
00662 
00663             if(mSimMasterChan != NULL)                  // Dettach from the channel
00664                chan->detach(mSimMasterChan);
00665          }
00666 
00667          chan->setScene(NULL);
00668          disp.pWin->removeChan(chan);     // Remove channel from pwin
00669          pfDelete( chan);                     // Delete the channel
00670       }
00671    }
00672 }

pfPipeWindow * vrj::PfDrawManager::allocatePipeWin unsigned    pipeNum [protected]
 

Definition at line 678 of file PfDrawManager.cpp.

References getPfPipe, and mPipeWindows.

Referenced by addDisplay, and initPipes.

00679 {
00680    pfPipeWindow* ret_val;
00681 
00682    // Grow the pipe window vector to the size we need for pipeNum.
00683    if ( mPipeWindows.size() <= pipeNum )
00684    {
00685       mPipeWindows.resize(pipeNum + 1);
00686    }
00687 
00688    if(mPipeWindows[pipeNum].size() > 0)   // Is one available
00689    {
00690       ret_val = mPipeWindows[pipeNum].back();
00691       mPipeWindows[pipeNum].pop_back();
00692    }
00693    else
00694    {
00695       ret_val = new pfPipeWindow(getPfPipe(pipeNum));         // Allocate a new one
00696    }
00697 
00698    vprASSERT((ret_val != NULL) && "We have a null pfPipeWindow*");
00699 
00700    return ret_val;
00701 }

void vrj::PfDrawManager::releasePipeWin pfPipeWindow *    pipeWin,
unsigned    pipeNum
[protected]
 

Definition at line 704 of file PfDrawManager.cpp.

References mPipeWindows.

Referenced by releaseDisplay.

00705 {
00706    mPipeWindows[pipeNum].push_back(pipeWin);
00707 }

std::vector< int > vrj::PfDrawManager::getMonoFBConfig vrj::Display   disp [protected]
 

Returns the needed mono frame buffer config.

Definition at line 748 of file PfDrawManager.cpp.

References configFrameBuffer, and mApp.

Referenced by addDisplay.

00749 {
00750    std::vector<int> mono_fb;
00751    mono_fb.push_back(PFFB_DOUBLEBUFFER);
00752    mono_fb.push_back(PFFB_RGBA);
00753    configFrameBuffer(disp, mono_fb);
00754 
00755    // Add application requests
00756    std::vector<int> app_fb = mApp->getFrameBufferAttrs();
00757    mono_fb.insert(mono_fb.end(), app_fb.begin(), app_fb.end());
00758 
00759 #ifdef VPR_OS_Win32
00760    mono_fb.push_back(0);
00761 #else
00762    mono_fb.push_back(None);
00763 #endif
00764 
00765    return mono_fb;
00766 }

std::vector< int > vrj::PfDrawManager::getStereoFBConfig vrj::Display   disp [protected]
 

Returns the needed stereo frame buffer config.

Definition at line 769 of file PfDrawManager.cpp.

References configFrameBuffer, and mApp.

Referenced by addDisplay.

00770 {
00771    std::vector<int> stereo_fb;
00772    stereo_fb.push_back(PFFB_DOUBLEBUFFER);
00773    stereo_fb.push_back(PFFB_RGBA);
00774    stereo_fb.push_back(PFFB_STEREO);
00775    configFrameBuffer(disp, stereo_fb);
00776 
00777    // Add application requests
00778    std::vector<int> app_fb = mApp->getFrameBufferAttrs();
00779    stereo_fb.insert(stereo_fb.end(), app_fb.begin(), app_fb.end());
00780 
00781 #ifdef VPR_OS_Win32
00782    stereo_fb.push_back(0);
00783 #else
00784    stereo_fb.push_back(None);
00785 #endif
00786 
00787    return stereo_fb;
00788 }

void vrj::PfDrawManager::configFrameBuffer vrj::Display   disp,
std::vector< int > &    attrs
[protected]
 

Adds frame buffer configuration options to the given vector based on the given vrj::Display object's OpenGL frame buffer configuration.

Definition at line 794 of file PfDrawManager.cpp.

References vrj::Display::getGlFrameBufferConfig, vrj::Display::getName, and vrjDBG_DRAW_MGR.

Referenced by getMonoFBConfig, and getStereoFBConfig.

00796 {
00797    int red_size(8), green_size(8), blue_size(8), alpha_size(8), db_size(16);
00798    bool want_fsaa(false);
00799 
00800    jccl::ConfigElementPtr fb_element = disp->getGlFrameBufferConfig();
00801 
00802    if ( fb_element.get() != NULL )
00803    {
00804       red_size   = fb_element->getProperty<int>("red_size");
00805       green_size = fb_element->getProperty<int>("green_size");
00806       blue_size  = fb_element->getProperty<int>("blue_size");
00807       alpha_size = fb_element->getProperty<int>("alpha_size");
00808       db_size    = fb_element->getProperty<int>("depth_buffer_size");
00809       want_fsaa  = fb_element->getProperty<bool>("fsaa_enable");
00810 
00811       if ( red_size < 0 )
00812       {
00813          vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_WARNING_LVL)
00814             << "WARNING: Red channel size was negative, set to: " << red_size
00815             << ".  Setting to 1.\n" << vprDEBUG_FLUSH;
00816          red_size = 1;
00817       }
00818 
00819       if ( green_size < 0 )
00820       {
00821          vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_WARNING_LVL)
00822             << "WARNING: Green channel size was negative, set to: "
00823             << green_size << ".  Setting to 1.\n" << vprDEBUG_FLUSH;
00824          green_size = 1;
00825       }
00826 
00827       if ( blue_size < 0 )
00828       {
00829          vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_WARNING_LVL)
00830             << "WARNING: Blue channel size was negative, set to: " << blue_size
00831             << ".  Setting to 1.\n" << vprDEBUG_FLUSH;
00832          blue_size = 1;
00833       }
00834 
00835       if ( alpha_size < 0 )
00836       {
00837          vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_WARNING_LVL)
00838             << "WARNING: Alpha channel size was negative, set to: "
00839             << alpha_size << ".  Setting to 1.\n" << vprDEBUG_FLUSH;
00840          alpha_size = 1;
00841       }
00842 
00843       if ( db_size < 0 )
00844       {
00845          vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_WARNING_LVL)
00846             << "WARNING: Depth buffer size was negative, set to: " << db_size
00847             << ".  Setting to 1.\n" << vprDEBUG_FLUSH;
00848          db_size = 1;
00849