Show
Ignore:
Timestamp:
08/30/05 16:41:08 (9 years ago)
Author:
robert
Message:

Clean up and fixes to GraphicThread? class, and osgcamera example.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgcamera/osgcamera.cpp

    r4446 r4477  
    4848    virtual void operator () (osg::GraphicsContext* context) 
    4949    { 
    50         std::cout<<"FrameOperation draw begin"<<context<<std::endl; 
    51  
    5250        _sceneView->setState(context->getState()); 
    5351        _sceneView->setProjectionMatrix(_camera->getProjectionMatrix()); 
     
    5755        _sceneView->cull(); 
    5856        _sceneView->draw(); 
    59  
    60         std::cout<<"FrameOperation draw end"<<context<<std::endl; 
    6157    } 
    6258     
     
    128124        } 
    129125 
    130         // realise the window 
    131         gfxc->realize(); 
    132  
    133126        camera->setGraphicsContext(gfxc.get()); 
    134127 
     
    142135        camera->setViewMatrix(viewMatrix); 
    143136 
    144  
     137        // graphics thread will realize the window. 
    145138        gfxc->createGraphicsThread(); 
    146139 
     
    163156    std::cout<<"nubmer of gfx."<<graphicsContextSet.size()<<std::endl; 
    164157 
    165  
    166     GraphicsContextSet::iterator gitr; 
    167     for(gitr = graphicsContextSet.begin(); 
    168         gitr != graphicsContextSet.end(); 
    169         ++gitr) 
    170     { 
    171         std::cout<<"Issue swap."<<std::endl; 
    172         osg::GraphicsContext* context = *gitr; 
    173         context->getGraphicsThread()->add(swapOp.get(), true); 
    174     } 
    175      
    176158    // record the timer tick at the start of rendering.     
    177159    osg::Timer_t start_tick = osg::Timer::instance()->tick(); 
     160    osg::Timer_t previous_tick = start_tick; 
    178161     
    179162    bool done = false;     
     
    182165    while( !done ) 
    183166    { 
    184         std::cout<<"Frame "<<frameNum<<std::endl; 
    185  
    186         frameStamp->setReferenceTime(osg::Timer::instance()->delta_s(start_tick,osg::Timer::instance()->tick())); 
     167 
     168        osg::Timer_t current_tick = osg::Timer::instance()->tick(); 
     169 
     170        frameStamp->setReferenceTime(osg::Timer::instance()->delta_s(start_tick,current_tick)); 
    187171        frameStamp->setFrameNumber(frameNum++); 
    188172         
    189         std::cout<<"Frame rate "<<(double)frameNum / frameStamp->getReferenceTime()<<std::endl; 
     173        std::cout<<"Frame rate "<<1.0/osg::Timer::instance()->delta_s(previous_tick,current_tick)<<std::endl; 
     174        previous_tick = current_tick; 
    190175 
    191176 
     
    201186        } 
    202187 
     188        GraphicsContextSet::iterator gitr; 
    203189        for(gitr = graphicsContextSet.begin(); 
    204190            gitr != graphicsContextSet.end(); 
     
    210196        } 
    211197 
    212         std::cout<<"Join frameEndBarrierOp block "<<std::endl; 
     198        osg::notify(osg::INFO)<<"Join frameEndBarrierOp block "<<std::endl; 
    213199        osg::Timer_t before_tick = osg::Timer::instance()->tick(); 
    214200        frameEndBarrierOp->block(); 
    215201        osg::Timer_t after_tick = osg::Timer::instance()->tick(); 
    216         std::cout<<"Leave frameEndBarrierOp block "<<osg::Timer::instance()->delta_s(before_tick,after_tick)<<std::endl; 
    217  
    218         std::cout<<"Join preSwapBarrierOp block "<<std::endl; 
     202        osg::notify(osg::INFO)<<"Leave frameEndBarrierOp block "<<osg::Timer::instance()->delta_s(before_tick,after_tick)<<std::endl; 
     203 
     204        osg::notify(osg::INFO)<<"Join preSwapBarrierOp block "<<std::endl; 
    219205        before_tick = osg::Timer::instance()->tick(); 
    220 //        preSwapBarrierOp->block(); 
    221206        after_tick = osg::Timer::instance()->tick(); 
    222         std::cout<<"Leave preSwapBarrierOp block "<<osg::Timer::instance()->delta_s(before_tick,after_tick)<<std::endl; 
     207        osg::notify(osg::INFO)<<"Leave preSwapBarrierOp block "<<osg::Timer::instance()->delta_s(before_tick,after_tick)<<std::endl; 
    223208 
    224209        for(gitr = graphicsContextSet.begin(); 
     
    227212        { 
    228213            osg::GraphicsContext* context = *gitr; 
    229             context->getGraphicsThread()->add(swapOp.get(), false); 
     214            context->getGraphicsThread()->add(swapOp.get(), true); 
    230215        } 
    231216