|
发表于 2012-4-6 21:12:49
|
显示全部楼层
本帖最后由 shuangying 于 2012-4-6 21:17 编辑
OSG-3.0-VC9,按flysky的指南都配置好了,为什么不能运行?求高手指教
源代码如下:- #include <osgViewer/Viewer>
- #include <osg/Geode>
- #include <osg/Geometry>
- #include <osg/Group>
- int main(int, char **)
- {
- osg::Geometry* pointsGeom = new osg::Geometry();
- osg::Vec3Array* vertices = new osg::Vec3Array;
- vertices->push_back(osg::Vec3(-1.02168, -2.15188e-09, 0.885735));
- vertices->push_back(osg::Vec3(-0.976368, -2.15188e-09, 0.832179));
- vertices->push_back(osg::Vec3(-0.873376, 9.18133e-09, 0.832179));
- vertices->push_back(osg::Vec3(-0.836299, -2.15188e-09, 0.885735));
- vertices->push_back(osg::Vec3(-0.790982, 9.18133e-09, 0.959889));
- pointsGeom->setVertexArray(vertices);
- osg::Vec4Array* colors = new osg::Vec4Array;
- colors->push_back(osg::Vec4(1.0f,1.0f,0.0f,1.0f));
- pointsGeom->setColorArray(colors);
- pointsGeom->setColorBinding(osg::Geometry::BIND_OVERALL);
- osg::Vec3Array* normals = new osg::Vec3Array;
- normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));
- pointsGeom->setNormalArray(normals);
- pointsGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);
- pointsGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POINTS,0,vertices->size()));
- osg::Geode* geode=new osg::Geode();
- // add the points geometry to the geode.
- geode->addDrawable(pointsGeom);
- osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
- osg::ref_ptr<osg::Group> root=new osg::Group;
- root->addChild(geode);
- viewer->setSceneData(root.get());
- viewer->run();
- return 0;
- }
复制代码 |
-
|