2005-08-16 21:29:07 +08:00
|
|
|
// C++ source file - (C) 2003 Robert Osfield, released under the OSGPL.
|
|
|
|
//
|
|
|
|
// Simple example of use of Producer::RenderSurface to create an OpenGL
|
|
|
|
// graphics window, and OSG for rendering.
|
|
|
|
|
2005-08-18 00:13:06 +08:00
|
|
|
|
2005-08-16 21:29:07 +08:00
|
|
|
#include <osgDB/ReadFile>
|
2006-12-20 00:12:29 +08:00
|
|
|
#include <osgViewer/Viewer>
|
2006-12-21 05:13:29 +08:00
|
|
|
#include <osgGA/TrackballManipulator>
|
2006-12-23 01:46:21 +08:00
|
|
|
#include <iostream>
|
2006-12-20 00:12:29 +08:00
|
|
|
|
|
|
|
int main( int argc, char **argv )
|
|
|
|
{
|
|
|
|
if (argc<2)
|
|
|
|
{
|
|
|
|
std::cout << argv[0] <<": requires filename argument." << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-12-23 01:46:21 +08:00
|
|
|
|
|
|
|
osg::DisplaySettings::instance()->setMaxNumberOfGraphicsContexts(2);
|
|
|
|
osg::Referenced::setThreadSafeReferenceCounting(true);
|
|
|
|
|
2006-12-20 00:12:29 +08:00
|
|
|
// load the scene.
|
|
|
|
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(argv[1]);
|
|
|
|
if (!loadedModel)
|
|
|
|
{
|
|
|
|
std::cout << argv[0] <<": No data loaded." << std::endl;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-12-22 00:56:20 +08:00
|
|
|
osgViewer::Viewer viewer;
|
2006-12-20 00:12:29 +08:00
|
|
|
|
2006-12-22 00:56:20 +08:00
|
|
|
viewer.setSceneData(loadedModel.get());
|
2006-12-20 00:12:29 +08:00
|
|
|
|
2006-12-22 00:56:20 +08:00
|
|
|
viewer.setCameraManipulator(new osgGA::TrackballManipulator());
|
|
|
|
viewer.getCamera()->setClearColor(osg::Vec4f(0.6f,0.6f,0.8f,1.0f));
|
2006-12-20 00:12:29 +08:00
|
|
|
|
2006-12-22 00:56:20 +08:00
|
|
|
viewer.setUpViewAcrossAllScreens();
|
|
|
|
viewer.realize();
|
2006-12-20 00:12:29 +08:00
|
|
|
|
2006-12-22 00:56:20 +08:00
|
|
|
while(!viewer.done())
|
|
|
|
{
|
|
|
|
viewer.frame();
|
2006-12-20 00:12:29 +08:00
|
|
|
}
|
2006-12-22 00:56:20 +08:00
|
|
|
|
2005-08-16 21:29:07 +08:00
|
|
|
return 0;
|
|
|
|
}
|