它有很多顶点属性派发器VertexArrayDispatch、ColorArrayDispatch、FogCoordArrayDispatch、SecondaryColorArrayDispatch、TexCoordArrayDispatch和VertexAttribArrayDispatch,负责将顶点属性的数据从cpu派发到gpu。VertexArrayDispatch调用glVertexPointer函数;ColorArrayDispatch调用glColorPointer函数;FogCoordArrayDispatch调用glFogCoordPointer函数;NormalArrayDispatch调用glNormalPointer函数;SecondaryColorArrayDispatch调用glSecondaryColorPointer函数;TexCoordArrayDispatch调用glTexCoordPointer函数;VertexAttribArrayDispatch负责调用glVertexAttrib*Pointer系列函数。
osg/VertexArrayState.cpp
void VertexArrayState::assignVertexArrayDispatcher()
{
if (correctArrayDispatchAssigned(_vertexArray.get())) return;
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
if (!_state->getUseVertexAttributeAliasing())
{
_vertexArray = new VertexArrayDispatch();
}
else
#endif
{
if (_vertexArray.valid()) return;
VAS_NOTICE<<"VertexArrayState::assignVertexArrayDispatcher() _state->getVertexAlias()._location="<<_state->getVertexAlias()._location<<std::endl;
_vertexArray = new VertexAttribArrayDispatch(_state->getVertexAlias()._location);
}
}
1、创建
1.1VertexArrayState的创建
当前窗体处于渲染状态时进行创建。