|
根据CWorld老师的自定义事件做的一个对菜单项的响应,想点击菜单项中的球体时,绘制出球体,此为背景。
一步步做,点击菜单项的时候,先试验下调用那个可爱的牛,正常,所以菜单项响应正常。
接下来绘制球体,并将球体结点加入到root结点下,编译通过,但运行时出现了dbgdel.cpp访问冲突,指向了下面这句:
/* verify block type */
_ASSERTE(_BLOCK_TYPE_IS_VALID(pHead->nBlockUse));
具体代码:
case SPHERE:
//root->addChild(osgDB::readNodeFile("cow.osg"));//------正常------//
root->addChild(drawSphere());
break;
....
球体的绘制:
osg::Node* DrawGeometry::drawSphere()
{
osg::ref_ptr<osg::Geode> geode=new osg::Geode;
osg::ref_ptr<osg::Group> root=new osg::Group();
float radius=5.0;
osg::ref_ptr<osg::TessellationHints> hints=new osg::TessellationHints;
hints->setDetailRatio(2.0f);
osg::ref_ptr<osg::ShapeDrawable> shape;
shape=new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(0.0f,0.0f,0.0f),radius),hints.get());
shape->setColor(osg::Vec4(0.8f,0.8f,1.0f,1.0f));
geode->addDrawable(shape.get());
root->addChild(geode.get());
return (osg::Node*)root;
}
问题出在哪啊? |
|