Show
Ignore:
Timestamp:
01/10/07 14:52:22 (7 years ago)
Author:
robert
Message:

Ported following examples to osgViewer:

osgparticleeffects
osgphotoalbum
osgpick
osgpoints
osgpointsprite
osgprecipitation
osgprerender
osgprerendercubemap
osgreflect
osgscalarbar
osgscribe
osgsequence
osgplanets

Files:
1 modified

Legend:

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

    r5636 r5954  
    1212#include <osgDB/ReadFile> 
    1313#include <osgUtil/Optimizer> 
    14 #include <osgProducer/Viewer> 
     14#include <osgViewer/Viewer> 
    1515 
    1616#include <osg/Point> 
     
    1818#include <osg/Texture2D> 
    1919#include <osg/PointSprite> 
     20 
     21#include <iostream> 
    2022 
    2123class KeyboardEventHandler : public osgGA::GUIEventHandler 
     
    110112 
    111113    // construct the viewer. 
    112     osgProducer::Viewer viewer(arguments); 
    113  
    114     // set up the value with sensible default event handlers. 
    115     viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); 
    116  
    117     // get details on keyboard and mouse bindings used by the viewer. 
    118     viewer.getUsage(*arguments.getApplicationUsage()); 
     114    osgViewer::Viewer viewer; 
    119115 
    120116    bool shader = false; 
     
    131127    while (arguments.read("--sprites")) { usePointSprites = true; }; 
    132128 
    133     // any option left unread are converted into errors to write out later. 
    134     arguments.reportRemainingOptionsAsUnrecognized(); 
    135  
    136     // report any errors if they have occured when parsing the program aguments. 
    137     if (arguments.errors()) 
    138     { 
    139         arguments.writeErrorMessages(std::cout); 
    140         return 1; 
    141     } 
    142      
    143129    if (arguments.argc()<=1) 
    144130    { 
     
    147133    } 
    148134 
    149     osg::Timer timer; 
    150     osg::Timer_t start_tick = timer.tick(); 
    151  
    152135    // read the scene from the list of file specified commandline args. 
    153136    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFiles(arguments); 
     
    159142        return 1; 
    160143    } 
    161  
    162     osg::Timer_t end_tick = timer.tick(); 
    163  
    164     std::cout << "Time to load = "<<timer.delta_s(start_tick,end_tick)<<std::endl; 
    165144 
    166145    // optimize the scene graph, remove rendundent nodes and state etc. 
     
    193172 
    194173    // register the handler for modifying the point size 
    195     viewer.getEventHandlerList().push_front(new KeyboardEventHandler(viewer.getGlobalStateSet())); 
     174    viewer.addEventHandler(new KeyboardEventHandler(viewer.getCamera()->getOrCreateStateSet())); 
    196175 
    197176 
     
    232211    } 
    233212 
    234  
    235  
    236     // create the windows and run the threads. 
    237     viewer.realize(); 
    238  
    239     while( !viewer.done() ) 
    240     { 
    241         // wait for all cull and draw threads to complete. 
    242         viewer.sync(); 
    243  
    244         // update the scene by traversing it with the the update visitor which will 
    245         // call all node update callbacks and animations. 
    246         viewer.update(); 
    247           
    248         // fire off the cull and draw traversals of the scene. 
    249         viewer.frame(); 
    250          
    251     } 
    252      
    253     // wait for all cull and draw threads to complete. 
    254     viewer.sync(); 
    255  
    256     // run a clean up frame to delete all OpenGL objects. 
    257     viewer.cleanup_frame(); 
    258  
    259     // wait for all the clean up frame to complete. 
    260     viewer.sync(); 
    261  
    262     return 0; 
     213    return viewer.run(); 
    263214} 
    264215