查看: 1525|回复: 2

osgTerrain TerrainTile Locator简单测试的错误!

[复制链接]

该用户从未签到

发表于 2011-8-16 13:39:45 | 显示全部楼层 |阅读模式
osg::Node* createClouds(double maxRange)
{
//Try to read from the WorldWind server
osg::ref_ptr<osg::Image> image = osgDB::readImageFile("E:\\OpenSceneGraph\\Data\\Images\\1.bmp");

if (!image.valid())
{
//OE_NOTICE << "Could not read clouds image " << std::endl;
  return NULL;
}
double min_lon = -180.0;
double min_lat = -90.0;
double max_lon = 180.0;
double max_lat = 90;
osgTerrain::TerrainTile* tile = new osgTerrain::TerrainTile();
osgTerrain:ocator* locator = new osgTerrain::Locator();
locator->setCoordinateSystemType( osgTerrain::Locator::GEOCENTRIC );
locator->setTransformAsExtents(
  osg:egreesToRadians( min_lon ),
  osg::DegreesToRadians( min_lat ),
  osg::DegreesToRadians( max_lon ),
  osg::DegreesToRadians( max_lat ));
osg::HeightField *hf = new osg::HeightField();
hf->allocate(64,64);
for(unsigned int i=0; i<hf->getHeightList().size(); i++ ) hf->getHeightList()[i] = 0.0;
hf->setOrigin( osg::Vec3d( min_lon, min_lat, 0.0 ) );
hf->setXInterval( (max_lon - min_lon)/(double)(hf->getNumColumns()-1) );
hf->setYInterval( (max_lat - min_lat)/(double)(hf->getNumRows()-1) );
hf->setBorderWidth( 0 );
osgTerrain::HeightFieldLayer* hf_layer = new osgTerrain::HeightFieldLayer();
hf_layer->setLocator( locator );
hf_layer->setHeightField( hf );
osgTerrain::ImageLayer* img_layer = new osgTerrain::ImageLayer( image.get() );
img_layer->setLocator( locator );
tile->setColorLayer( 0, img_layer );
tile->setLocator( locator );
tile->setTerrainTechnique( new osgTerrain::GeometryTechnique() );
tile->setElevationLayer( hf_layer );
tile->setRequiresNormals( true );
tile->getOrCreateStateSet()->setAttributeAndModes(new CullFace(CullFace::BACK), StateAttribute::ON);
tile->getOrCreateStateSet()->setMode(GL_LIGHTING, StateAttribute::OFF);
double scale = 1.01;
osg::MatrixTransform* mt = new osg::MatrixTransform;
mt->setMatrix(osg::Matrixd::scale(scale, scale, scale));
mt->addChild(tile);

osg::LOD *lod = new LOD;
lod->addChild(mt, maxRange, FLT_MAX);
return lod;
}

int _tmain(int argc, _TCHAR* argv[])
{

osgViewer::Viewer viewer;
osg::ref_ptr<osg::Group>group = new osg::Group();

group->addChild(createClouds(osg::WGS_84_RADIUS_EQUATOR * 2.0));
osgUtil::Optimizer optimizer;
optimizer.optimize(group.get());

viewer.setSceneData(group.get());
viewer.realize();
return viewer.run();
}
测试代码提示错误:glGenbuffers not supported by openGL driver 怎么改?

该用户从未签到

发表于 2011-8-17 09:55:50 | 显示全部楼层
glGenbuffers not supported by openGL driver
这个提示不是已经很明确了吗,您的显卡是清朝的。。。

该用户从未签到

发表于 2011-8-17 14:57:19 | 显示全部楼层
嘻嘻,明末清初的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

OSG中国官方论坛-有您OSG在中国才更好

网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

联系我们

  • 工作时间:09:00--18:00
  • 反馈邮箱:1315785073@qq.com
快速回复 返回顶部 返回列表