1、定义回调类
class MyDrawCallback : public osg::Drawable::DrawCallback
{
public:
void drawImplementation(osg::RenderInfo &, const osg::Drawable *) const{
GLenum errorNo;
errorNo = glGetError();
}
};
2、设置回调类
osg::ref_ptr<osg::Node> cowModel = osgDB::readRefNodeFile("cow111.osg");
osg::Group* ttt=cowModel->asGroup();
osg::Geometry* geom = ttt->getChild(0)->asGeode()->getChild(0)->asGeometry();
geom->setDrawCallback(new MyDrawCallback());