- osgearth_shadergen ,使用.osgearth_shadergen初始化多个模型,在退出程序时会崩溃;
解决方案:使用osgEarth::Registry::shaderGenerator().run(child);代替osgDB::readRefNodeFile(“…/data/axes.osgt.osgearth_shadergen”)的形式。 - drawImplementation ,当geometry使用useVertexArrayObject时,在执行完draw绘制接口后,系统崩溃到程序外(GPU).
解决方案:在draw之后执行unbindVertexBufferObject()和unbindElementBufferObject()以“unbind the VBO’s if any are used.”,完整用例如下:
void drawImplementation(osg::RenderInfo& renderInfo, const osg::Drawable* drawable) const
{
const osg::Geometry* geom = static_cast<const osg::Geometry*>(drawable);
geom->drawVertexArraysImplementation(renderInfo);
auto& state = *renderInfo.getState();
for (int i = 0; i < geom->getNumPrimitiveSets(); ++i)
{
osg::PrimitiveSet* pset = const_cast<osg::PrimitiveSet*>(geom->getPrimitiveSet(i));
pset->setNumInstances(_numInstancesToDraw);
pset->draw(state, true);
}
// unbind the VBO's if any are used.
#if OSG_MIN_VERSION_REQUIRED(3,5,6)
if (!state.useVertexArrayObject(true) || state.getCurrentVertexArrayState()->getRequiresSetArrays())
#endif
{
state.unbindVertexBufferObject();
state.unbindElementBufferObject();
}
}
3.待续···