OSG 与QT 结合

#include 

#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 



int main( int argc, char** argv )
{
	QApplication app(argc, argv);    
	osgQt::initQtWindowingSystem();

	osg::Group* sceneroot = new osg::Group;
 
	 sceneroot->addChild(osgDB::readNodeFile("cow.osg"));
	 osg::ref_ptr viewer = new osgViewer::Viewer;
	 viewer->addEventHandler( new osgGA::StateSetManipulator(viewer->getCamera()->getOrCreateStateSet()) );
	 viewer->addEventHandler(new osgViewer::StatsHandler);


	viewer->setSceneData( sceneroot );
	viewer->setCameraManipulator( new osgGA::TrackballManipulator );
	osgQt::setViewer( viewer.get() );

	osgQt::GLWidget* glw = new osgQt::GLWidget;
	osgQt::GraphicsWindowQt* graphicswin = new osgQt::GraphicsWindowQt(glw);
	 
	viewer->getCamera()->setViewport( new osg::Viewport(0, 0, glw->width(), glw->height() ) );
	viewer->getCamera()->setGraphicsContext( graphicswin );

	glw->show();

	return app.exec();
}



你可能感兴趣的:(OSG)