osg.MultiDrawArraysIndirect是OpenSceneGraph的一个绘制命令,用于多次绘制不同的几何体元素。
class MultiDrawArraysIndirect : public DrawArraysIndirectCommand
MultiDrawArraysIndirect(GLenum mode = osg::PrimitiveSet::TRIANGLES,
const BufferObject *indexPointer = nullptr,
const osg::Vec4i& indirect = osg::Vec4i())
其中,参数意义如下:
void draw(osg::State & state, bool useVertexBufferObjects = false) const override
绘制函数,用于在OpenGL中执行绘制命令。
osg::ref_ptr<osg::MultiDrawArraysIndirect> mdraw = new osg::MultiDrawArraysIndirect();
mdraw->setCount(2);
mdraw->setFirst(0);
mdraw->addDrawArraysIndirectCommand(osg::DrawArraysIndirectCommand(GL_TRIANGLES, 0, 3, 0));
mdraw->addDrawArraysIndirectCommand(osg::DrawArraysIndirectCommand(GL_TRIANGLES, 3, 6, 0));
osg::ref_ptr<osg::Geometry> geom = new osg::Geometry();
geom->addPrimitiveSet(mdraw);