|
本帖最后由 令棋者 于 2014-3-31 21:37 编辑
求助大神,我想利用利用osg导出图片,网上参考了一个例子,但是不行,求指教,谢谢!
#include "osgViewer/Viewer"
#include "osgDB/WriteFile"
#include "osgDB/ReadFile"
#include "osgGA/TrackballManipulator"
#include <osgViewer/GraphicsWindow>
void main()
{
//////////////////////////////////////////////////////////////////////////
//得到屏幕分辨率
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
///////////////////////////////////////////////////////////////////////////
osgViewer::Viewer v;
v.setSceneData(osgDB::readNodeFile("axes.osg"));
v.setCameraManipulator(new osgGA::TrackballManipulator());
v.frame();
osg::ref_ptr<osg::Image> image = new osg::Image;
image->readPixels(0,0,width,height, GL_RGB,GL_UNSIGNED_BYTE);
osgDB::writeImageFile(*image,"abc.jpg"); |
|