|
按照array版主给我的提示,
创建一个四边形然后输出OSG文件的过程中,
在执行osgDB::writeNodeFile时抛出异常,
提示信息为:“vertexOut.exe 中的 0x0043f19c 处未处理的异常: 0xC0000005: 读取位置 0xfeeeff06 时发生访问冲突”
一直无法找到问题出处,无法输出文件。 请问这是我配置的问题吗,应该如何解决
我的程序如下:- // Windows 头文件:
- #include <windows.h>
- // C 运行时头文件
- #include <stdlib.h>
- #include <tchar.h>
- //OSG库
- #include <osgDB/ReadFile>
- #include <osgViewer/Viewer>
- #include <osg/Node>
- #include <osg/Geode>
- #include <osg/Geometry>
- #include <osgDB/Registry>
- #include <osgDB/WriteFile>
- osg::ref_ptr<osg::Node> createSenseGraph();
- using std::endl;
- osg::ref_ptr<osg::Node> createSenseGraph();
- int APIENTRY _tWinMain(HINSTANCE hInstance,
- HINSTANCE hPrevInstance,
- LPTSTR lpCmdLine,
- int nCmdShow)
- {
- osg::Node *node=createSenseGraph().get();
- osgDB::writeNodeFile(*node,"C:\\a.osg");
- return 0;
- }
- osg::ref_ptr<osg::Node> createSenseGraph()
- {
- osg::ref_ptr<osg::Geometry> geom=new osg::Geometry();
- osg::ref_ptr<osg::Vec3Array> v=new osg::Vec3Array();
- geom->setVertexArray(v.get());
- v->push_back(osg::Vec3(-1.f,0.f,-1.f));
- v->push_back(osg::Vec3(1.f,0,-1.f));
- v->push_back(osg::Vec3(1.f,0,1.f));
- v->push_back(osg::Vec3(-1.f,0,1.f));
- osg::ref_ptr<osg::Vec4Array> c=new osg::Vec4Array();
- geom->setColorArray(c.get());
- geom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
- c->push_back(osg::Vec4(1.f,0,0,1.f));
- c->push_back(osg::Vec4(0,1.f,0,1.f));
- c->push_back(osg::Vec4(0,0,1.f,1.f));
- c->push_back(osg::Vec4(1.f,1.f,1.f,1.f));
- osg::ref_ptr<osg::Vec3Array> n=new osg::Vec3Array();
- geom->setNormalArray(n.get());
- geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
- n->push_back(osg::Vec3(0,-1.f,0));
- geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4));
- osg::ref_ptr<osg::Geode> geode=new osg::Geode();
- geode->addDrawable(geom.get());
- return geode.get();
- }
复制代码
[ 本帖最后由 array 于 2009-2-1 12:14 编辑 ] |
|