root/OpenSceneGraph/trunk/examples/osgcamera/osgcamera.cpp @ 5843

Revision 5843, 1.1 kB (checked in by robert, 7 years ago)

Implemented perliminary multi-threading support in osgViewer::Viewer

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1// C++ source file - (C) 2003 Robert Osfield, released under the OSGPL.
2//
3// Simple example of use of Producer::RenderSurface to create an OpenGL
4// graphics window, and OSG for rendering.
5
6
7#include <osgDB/ReadFile>
8#include <osgViewer/Viewer>
9#include <osgGA/TrackballManipulator>
10#include <iostream>
11
12int main( int argc, char **argv )
13{
14    if (argc<2)
15    {
16        std::cout << argv[0] <<": requires filename argument." << std::endl;
17        return 1;
18    }
19
20
21    osg::DisplaySettings::instance()->setMaxNumberOfGraphicsContexts(2);
22    osg::Referenced::setThreadSafeReferenceCounting(true);
23
24    // load the scene.
25    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(argv[1]);
26    if (!loadedModel)
27    {
28        std::cout << argv[0] <<": No data loaded." << std::endl;
29        return 1;
30    }
31
32    osgViewer::Viewer viewer;
33   
34    viewer.setSceneData(loadedModel.get());
35
36    viewer.setCameraManipulator(new osgGA::TrackballManipulator());
37    viewer.getCamera()->setClearColor(osg::Vec4f(0.6f,0.6f,0.8f,1.0f));
38
39    viewer.setUpViewAcrossAllScreens();
40    viewer.realize();
41
42    while(!viewer.done())
43    {
44        viewer.frame();
45    }
46
47    return 0;
48}
Note: See TracBrowser for help on using the browser.