Show
Ignore:
Timestamp:
02/09/05 11:39:45 (10 years ago)
Author:
robert
Message:

Added osg::BufferObject? and a made a number associated to accomodate this
new class. osg::BufferObject? wraps up OpenGL pixel and array buffer objects.
Currently implementation is work in progress.

Files:
1 modified

Legend:

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

    r3812 r3819  
    1717#include <osgGA/TrackballManipulator> 
    1818 
     19osg::ImageStream* s_imageStream = 0; 
     20class PostSwapFinishCallback : public Producer::Camera::Callback 
     21{ 
     22public: 
     23 
     24    PostSwapFinishCallback() {} 
     25 
     26    virtual void operator()(const Producer::Camera& camera) 
     27    { 
     28        // osg::Timer_t start_tick = osg::Timer::instance()->tick(); 
     29         
     30        osgProducer::OsgSceneHandler* sh = const_cast<osgProducer::OsgSceneHandler*>(dynamic_cast<const osgProducer::OsgSceneHandler*>(camera.getSceneHandler())); 
     31     
     32        if (s_imageStream && s_imageStream->getPixelBufferObject()) s_imageStream->getPixelBufferObject()->compileBuffer(*(sh->getSceneView()->getState())); 
     33        // glFinish(); 
     34 
     35        //osg::notify(osg::NOTICE)<<"callback after PBO "<<osg::Timer::instance()->delta_m(start_tick,osg::Timer::instance()->tick())<<"ms"<<std::endl; 
     36    } 
     37}; 
     38 
    1939class MovieEventHandler : public osgGA::GUIEventHandler 
    2040{ 
     
    7898        inline void apply(osg::ImageStream* imagestream) 
    7999        { 
    80             if (imagestream) _imageStreamList.push_back(imagestream);  
     100            if (imagestream) 
     101            { 
     102                _imageStreamList.push_back(imagestream);  
     103                s_imageStream = imagestream; 
     104            } 
    81105        } 
    82106         
     
    259283    } 
    260284 
     285    // set up a post swap callback to flush deleted GL objects and compile new GL objects             
     286    for(unsigned int cameraNum=0;cameraNum<viewer.getNumberOfCameras();++cameraNum) 
     287    { 
     288        Producer::Camera* camera=viewer.getCamera(cameraNum); 
     289        camera->addPostSwapCallback(new PostSwapFinishCallback()); 
     290    } 
     291 
    261292    // set the scene to render 
    262293    viewer.setSceneData(geode);