osgearth API编程动态建立一个地球!

    在研究了怎么样用earth文件来建立地球之后,我开始着手实现很多osgearth学习笔记中的API编程来建立地球。可是我照着其中的例子( http://blog.csdn.net/whucv/article/details/8474917)做却出现了问题如下所示: osgearth API编程动态建立一个地球!_第1张图片

经过半天的查找资料我把 我的程序代码改成了下面所示就成功显示了一个简单的地球。希望大家可以参考一下!

代码:

#include
#include
#include
#include
#include   

using namespace osgEarth;
using namespace osgEarth::Drivers;

int _tmain(int argc, _TCHAR* argv[])
{
 osg::ref_ptr viewer=new osgViewer::Viewer();  
 Map *map=new Map;
 osgEarth::Drivers::GDALOptions layerOpt;
 layerOpt.url() = osgEarth::URI("E:\\vs2010Progam Files\\osgVR74\\osgVR74\\world.tif");

 std::string fileName = "E:\\vs2010Progam Files\\osgVR74\\osgVR74\\world.tif";
 osg::ref_ptr newLayer = new osgEarth::ImageLayer(osgEarth::ImageLayerOptions(fileName, layerOpt));

 map->addImageLayer(newLayer.get());

 MapNode* mapNode=new MapNode(map);
 osgUtil::Optimizer optimizer; 
 optimizer.optimize(mapNode);
 viewer->setSceneData(mapNode);
 viewer->realize(); 
 viewer->run();

return 0;

}

你可能感兴趣的:(osgearth,OSG,编程)