Hi,

I add some code fragments to point out whats going on. (thread a is app, 
thread b is gui/rendering)

----------- Startup phase -------------
Thread A:
    OSG::Init()

Thread B:
    OSG::ExternalThread::get("GUIThread")->initialize(1) // Use aspect 1

    // Wait for app thread to run into update() and be ready for sync
    OSG::Barrier::get("ModelSyncBarrier")->enter(2);
    (dynamic_cast<OSG::Thread 
*>(OSG::ThreadManager::getAppThread()))->getChangeList()->applyAndClear();    
               
    OSG::Barrier::get("ModelSyncBarrier")->enter(2);
 
Thread A: relevant code to show that setup navigation / rendering is 
going on
    _pRenderAction = OSG::RenderAction::create();
    // Don't draw or test any object taking up less than 15 pixels
    _pRenderAction->setOcclusionCullingMinimumFeatureSize(15);
    ...
    _pNavigator->setMode(OSG::Navigator::TRACKBALL);
    // will not work because the port of the passive window is not yet 
initialized/used
    // currently this is being worked around by setting it again in redraw()
    _pNavigator->setViewport(_pWin->getPort(0));
    _pNavigator->setCameraTransformation(pCart);       
    _pNavigator->updateCameraTransformation();
    ...
   
Thread A: this is the relevant code in update()
    if (m_syncForRenderingNeeded)
    {       
        if (_pNavigator)
            _pNavigator->updateCameraTransformation();

        OSG::commitChanges();

        m_syncBarrierP->enter(2);
        m_syncBarrierP->enter(2);

        m_syncForRenderingNeeded = false;
    }

----------- Running phase, update() is called continuously by the app 
core -------------

Thread B: redraw()
    m_syncForRenderingNeeded = true;
   
    m_syncBarrierP->enter(2);   
    m_appThreadP->getChangeList()->applyAndClear();
    m_syncBarrierP->enter(2);   

    OSG::commitChanges();
   
Thread A:
    update()

----------- Model loading -------------
Thread A: loadModel()
    ...
    OSG::NodeMTRefPtr pNewNode = OSG::Node::create();
    OSG::GroupMTRefPtr g = OSG::Group::create();     
    pNewNode->setCore(g);             
    
pNewNode->addChild(OSG::SceneFileHandler::the()->read(file.c_str()));   
    pParentNode->addChild(pNewNode);

    setRoot(pParentNode);
   
    showAll();
    ...

Thread B:
    redraw()
   
Thread A:
    update()


Cheers,
Christoph

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to