void Geometry::drawImplementation(RenderInfo& renderInfo) const
{
State& state = *renderInfo.getState();
// unsigned int contextID = state.getContextID();
// osg::notify(osg::NOTICE)<<"Geometry::drawImplementation"<<std::endl;
if (_internalOptimizedGeometry.valid())
{
_internalOptimizedGeometry->drawImplementation(renderInfo);
return;
}
const Extensions* extensions = getExtensions(state.getContextID(),true);
if( !( ( _vertexData.array.valid() && _vertexData.array->getNumElements() != 0 ) ||
( _vertexAttribList.size() > 0 &&
_vertexAttribList[0].array.valid() &&
_vertexAttribList[0].array->getNumElements() != 0 ) ) )
{
return;
}
if( ( _vertexData.indices.valid() && _vertexData.indices->getNumElements() == 0 ) ||
( _vertexAttribList.size() > 0 &&
_vertexAttribList[0].indices.valid() &&
_vertexAttribList[0].indices->getNumElements() == 0 ) )
{
return;
}
DrawNormal drawNormal(_normalData.array.get(),_normalData.indices.get());
DrawColor drawColor(_colorData.array.get(),_colorData.indices.get());
DrawSecondaryColor drawSecondaryColor(_secondaryColorData.array.get(),_secondaryColorData.indices.get(),extensions);
DrawFogCoord drawFogCoord(_fogCoordData.array.get(),_fogCoordData.indices.get(),extensions);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Set up secondary color if required.
//
AttributeBinding secondaryColorBinding = _secondaryColorData.binding;
if (secondaryColorBinding!=BIND_OFF && !extensions->isSecondaryColorSupported())
{
// switch off if not supported or have a valid data.
secondaryColorBinding = BIND_OFF;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Set up fog coord if required.
//
AttributeBinding fogCoordBinding = _fogCoordData.binding;
if (fogCoordBinding!=BIND_OFF && !extensions->isFogCoordSupported())
{
// switch off if not supported or have a valid data.
fogCoordBinding = BIND_OFF;
}
unsigned int normalIndex = 0;
unsigned int colorIndex = 0;
unsigned int secondaryColorIndex = 0;
unsigned int fogCoordIndex = 0;
#if USE_DEFAULT_NORMAL
// if no values are defined for normal and color provide some defaults...
if (_normalData.binding==BIND_OFF) glNormal3f(0.0f,0.0f,1.0f);
#endif
#if USE_DEFAULT_COLOUR
if (_colorData.binding==BIND_OFF) glColor4f(1.0f,1.0f,1.0f,1.0f);
#endif
typedef std::vector< ref_ptr<DrawVertexAttrib> > DrawVertexAttribList;
typedef std::map< Geometry::AttributeBinding, DrawVertexAttribList> DrawVertexAttribMap;
DrawVertexAttribMap drawVertexAttribMap;
bool vertexVertexAttributesSupported = extensions->isVertexProgramSupported();
bool handleVertexAttributes = (!_vertexAttribList.empty() && vertexVertexAttributesSupported);
bool usingVertexBufferObjects = _useVertexBufferObjects && state.isVertexBufferObjectSupported();
if (areFastPathsUsed())
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// fast path.
//
if (usingVertexBufferObjects) //用顶点缓冲区
{
//
// Vertex Buffer Object path for defining vertex arrays.
//
state.setNormalPointer(_normalData.binding==BIND_PER_VERTEX ? _normalData.array.get() : 0);
state.setColorPointer(_colorData.binding==BIND_PER_VERTEX ? _colorData.array.get() : 0);
state.setSecondaryColorPointer(_secondaryColorData.binding==BIND_PER_VERTEX ? _secondaryColorData.array.get() : 0);
state.setFogCoordPointer(_fogCoordData.binding==BIND_PER_VERTEX ? _fogCoordData.array.get() : 0);
unsigned int unit;
for(unit=0;unit<_texCoordList.size();++unit)
{
state.setTexCoordPointer(unit, _texCoordList[unit].array.get());
}
state.disableTexCoordPointersAboveAndIncluding(unit);
if( handleVertexAttributes )
{
unsigned int index;
for( index = 0; index < _vertexAttribList.size(); ++index )
{
const Array* array = _vertexAttribList[index].array.get();
const AttributeBinding ab = _vertexAttribList[index].binding;
state.setVertexAttribPointer(index, (ab==BIND_PER_VERTEX ? array : 0), _vertexAttribList[index].normalize);
if(array && ab!=BIND_PER_VERTEX)
{
const IndexArray* indexArray = _vertexAttribList[index].indices.get();
if( indexArray && indexArray->getNumElements() > 0 )
{
drawVertexAttribMap[ab].push_back(
new DrawVertexAttrib(extensions,index,_vertexAttribList[index].normalize,array,indexArray) );
}
else
{
drawVertexAttribMap[ab].push_back(
new DrawVertexAttrib(extensions,index,_vertexAttribList[index].normalize,array,0) );
}
}
}
state.disableVertexAttribPointersAboveAndIncluding( index );
}
else if (vertexVertexAttributesSupported)
{
state.disableVertexAttribPointersAboveAndIncluding( 0 );
}
state.setVertexPointer(_vertexData.array.get());//传入顶点数组及指针
}
else
{
//std::cout << "none VertexBuffer path"<<std::endl;
//
// Non Vertex Buffer Object path for defining vertex arrays.
//
if( _vertexData.array.valid() )
state.setVertexPointer(_vertexData.array->getDataSize(),_vertexData.array->getDataType(),0,_vertexData.array->getDataPointer());
else
state.disableVertexPointer();
if (_normalData.binding==BIND_PER_VERTEX && _normalData.array.valid())
state.setNormalPointer(_normalData.array->getDataType(),0,_normalData.array->getDataPointer());
else
state.disableNormalPointer();
if (_colorData.binding==BIND_PER_VERTEX && _colorData.array.valid())
state.setColorPointer(_colorData.array->getDataSize(),_colorData.array->getDataType(),0,_colorData.array->getDataPointer());
else
state.disableColorPointer();
if (secondaryColorBinding==BIND_PER_VERTEX && _secondaryColorData.array.valid())
state.setSecondaryColorPointer(_secondaryColorData.array->getDataSize(),_secondaryColorData.array->getDataType(),0,_secondaryColorData.array->getDataPointer());
else
state.disableSecondaryColorPointer();
if (fogCoordBinding==BIND_PER_VERTEX && _fogCoordData.array.valid())
state.setFogCoordPointer(GL_FLOAT,0,_fogCoordData.array->getDataPointer());
else
state.disableFogCoordPointer();
unsigned int unit;
for(unit=0;unit<_texCoordList.size();++unit)
{
const Array* array = _texCoordList[unit].array.get();
if (array)
state.setTexCoordPointer(unit,array->getDataSize(),array->getDataType(),0,array->getDataPointer());
else
state.disableTexCoordPointer(unit);
}
state.disableTexCoordPointersAboveAndIncluding(unit);
if( handleVertexAttributes )
{
unsigned int index;
for( index = 0; index < _vertexAttribList.size(); ++index )
{
const Array* array = _vertexAttribList[index].array.get();
const AttributeBinding ab = _vertexAttribList[index].binding;
if( ab == BIND_PER_VERTEX && array )
{
state.setVertexAttribPointer( index, array->getDataSize(), array->getDataType(),
_vertexAttribList[index].normalize, 0, array->getDataPointer() );
}
else
{
if( array )
{
const IndexArray* indexArray = _vertexAttribList[index].indices.get();
if( indexArray && indexArray->getNumElements() > 0 )
{
drawVertexAttribMap[ab].push_back(
new DrawVertexAttrib(extensions,index,_vertexAttribList[index].normalize,array,indexArray) );
}
else
{
drawVertexAttribMap[ab].push_back(
new DrawVertexAttrib(extensions,index,_vertexAttribList[index].normalize,array,0) );
}
}
state.disableVertexAttribPointer( index );
}
}
state.disableVertexAttribPointersAboveAndIncluding( index );
}
else if (vertexVertexAttributesSupported)
{
state.disableVertexAttribPointersAboveAndIncluding( 0 );
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// pass the overall binding values onto OpenGL.
//
if (_normalData.binding==BIND_OVERALL) drawNormal(normalIndex++);
if (_colorData.binding==BIND_OVERALL) drawColor(colorIndex++);
if (secondaryColorBinding==BIND_OVERALL) drawSecondaryColor(secondaryColorIndex++);
if (fogCoordBinding==BIND_OVERALL) drawFogCoord(fogCoordIndex++);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_OVERALL];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// draw the primitives themselves.
//
for(PrimitiveSetList::const_iterator itr=_primitives.begin();
itr!=_primitives.end();
++itr)
{
if (_normalData.binding==BIND_PER_PRIMITIVE_SET) drawNormal(normalIndex++);
if (_colorData.binding==BIND_PER_PRIMITIVE_SET) drawColor(colorIndex++);
if (secondaryColorBinding==BIND_PER_PRIMITIVE_SET) drawSecondaryColor(secondaryColorIndex++);
if (fogCoordBinding==BIND_PER_PRIMITIVE_SET) drawFogCoord(fogCoordIndex++);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_PRIMITIVE_SET];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
(*itr)->draw(state, usingVertexBufferObjects);//内部生成顶点纹理索引,并绑定画图
}
if (usingVertexBufferObjects)
{
#if 1
state.unbindVertexBufferObject();
state.unbindElementBufferObject();
#endif
}
}
else
{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// slow path.
//
typedef std::vector< ref_ptr<DrawMultiTexCoord> > DrawTexCoordList;
DrawTexCoordList drawTexCoordList;
drawTexCoordList.reserve(_texCoordList.size());
// fallback if multitexturing not supported.
ref_ptr<DrawTexCoord> drawTextCoord;
if (extensions->isMultiTexSupported() && _texCoordList.size()>1)
{
// multitexture supported..
for(unsigned int unit=0;unit!=_texCoordList.size();++unit)
{
const ArrayData& texcoordData = _texCoordList[unit];
if (texcoordData.array.valid() && texcoordData.array->getNumElements()>0)
{
if (texcoordData.indices.valid() && texcoordData.indices->getNumElements()>0)
{
drawTexCoordList.push_back(new DrawMultiTexCoord(GL_TEXTURE0+unit,texcoordData.array.get(),texcoordData.indices.get(),
extensions));
}
else
{
drawTexCoordList.push_back(new DrawMultiTexCoord(GL_TEXTURE0+unit,texcoordData.array.get(),0,
extensions));
}
}
}
}
else
{
if (!_texCoordList.empty())
{
const ArrayData& texcoordData = _texCoordList[0];
if (texcoordData.array.valid() && texcoordData.array->getNumElements()>0)
{
if (texcoordData.indices.valid())
{
if (texcoordData.indices->getNumElements()>0)
{
drawTextCoord = new DrawTexCoord(texcoordData.array.get(),texcoordData.indices.get());
}
}
else
{
drawTextCoord = new DrawTexCoord(texcoordData.array.get(),0);
}
}
}
}
if(handleVertexAttributes)
{
unsigned int index;
for( index = 1; index < _vertexAttribList.size(); ++index )
{
const ArrayData& vertAttribData = _vertexAttribList[index];
if( vertAttribData.array.valid() && vertAttribData.array->getNumElements() > 0 )
{
if( vertAttribData.indices.valid() && vertAttribData.indices->getNumElements() > 0 )
{
drawVertexAttribMap[vertAttribData.binding].push_back(
new DrawVertexAttrib(extensions,index,vertAttribData.normalize,vertAttribData.array.get(),vertAttribData.indices.get() ));
}
else
{
drawVertexAttribMap[vertAttribData.binding].push_back(
new DrawVertexAttrib(extensions,index,vertAttribData.normalize,vertAttribData.array.get(),0) );
}
}
}
}
// disable all the vertex arrays in the slow path as we are
// sending everything using glVertex etc.
state.disableAllVertexArrays();
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// pass the overall binding values onto OpenGL.
//
if (_normalData.binding==BIND_OVERALL) drawNormal(normalIndex++);
if (_colorData.binding==BIND_OVERALL) drawColor(colorIndex++);
if (secondaryColorBinding==BIND_OVERALL) drawSecondaryColor(secondaryColorIndex++);
if (fogCoordBinding==BIND_OVERALL) drawFogCoord(fogCoordIndex++);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_OVERALL];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
// set up vertex functor.
DrawVertex drawVertex(_vertexData.array.get(),_vertexData.indices.get());
bool useVertexAttrib = _vertexAttribList.size() > 0 &&
_vertexAttribList[0].array.valid() &&
_vertexAttribList[0].indices->getNumElements();
ref_ptr<DrawVertexAttrib> drawVertexAttribZero;
if( useVertexAttrib )
{
drawVertexAttribZero = new DrawVertexAttrib(extensions,0,
_vertexAttribList[0].normalize,_vertexAttribList[0].array.get(),
_vertexAttribList[0].indices.get());
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// draw the primitives themselves.
//
for(PrimitiveSetList::const_iterator itr=_primitives.begin();
itr!=_primitives.end();
++itr)
{
if (_normalData.binding==BIND_PER_PRIMITIVE_SET) drawNormal(normalIndex++);
if (_colorData.binding==BIND_PER_PRIMITIVE_SET) drawColor(colorIndex++);
if (secondaryColorBinding==BIND_PER_PRIMITIVE_SET) drawSecondaryColor(secondaryColorIndex++);
if (fogCoordBinding==BIND_PER_PRIMITIVE_SET) drawFogCoord(fogCoordIndex++);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_PRIMITIVE_SET];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
const PrimitiveSet* primitiveset = itr->get();
GLenum mode=primitiveset->getMode();
unsigned int primLength;
switch(mode)
{
case(GL_POINTS): primLength=1; break;
case(GL_LINES): primLength=2; break;
case(GL_TRIANGLES): primLength=3; break;
case(GL_QUADS): primLength=4; break;
default: primLength=0; break; // compute later when =0.
}
// draw primitives by the more flexible "slow" path,
// sending OpenGL glBegin/glVertex.../glEnd().
switch(primitiveset->getType()) //glBegin()及glEnd()画图
{
case(PrimitiveSet::DrawArraysPrimitiveType):
{
if (primLength==0) primLength=primitiveset->getNumIndices();
const DrawArrays* drawArray = static_cast<const DrawArrays*>(primitiveset);
glBegin(mode);
unsigned int primCount=0;
unsigned int indexEnd = drawArray->getFirst()+drawArray->getCount();
for(unsigned int vindex=drawArray->getFirst();
vindex<indexEnd;
++vindex,++primCount)
{
if ((primCount%primLength)==0)
{
if (_normalData.binding==BIND_PER_PRIMITIVE) drawNormal(normalIndex++);
if (_colorData.binding==BIND_PER_PRIMITIVE) drawColor(colorIndex++);
if (secondaryColorBinding==BIND_PER_PRIMITIVE) drawSecondaryColor(secondaryColorIndex++);
if (fogCoordBinding==BIND_PER_PRIMITIVE) drawFogCoord(fogCoordIndex++);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_PRIMITIVE];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
}
if (_normalData.binding==BIND_PER_VERTEX) drawNormal(vindex);
if (_colorData.binding==BIND_PER_VERTEX) drawColor(vindex);
if (secondaryColorBinding==BIND_PER_VERTEX) drawSecondaryColor(vindex);
if (fogCoordBinding==BIND_PER_VERTEX) drawFogCoord(vindex);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_VERTEX];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
for(DrawTexCoordList::iterator texItr=drawTexCoordList.begin();
texItr!=drawTexCoordList.end();
++texItr)
{
(*(*texItr))(vindex);
}
if (drawTextCoord.valid()) (*drawTextCoord)(vindex);
if( useVertexAttrib )
{
(*drawVertexAttribZero)(vindex);
}
else
{
drawVertex(vindex);
}
}
glEnd();
break;
}
case(PrimitiveSet::DrawArrayLengthsPrimitiveType):
{
const DrawArrayLengths* drawArrayLengths = static_cast<const DrawArrayLengths*>(primitiveset);
unsigned int vindex=drawArrayLengths->getFirst();
for(DrawArrayLengths::const_iterator primItr=drawArrayLengths->begin();
primItr!=drawArrayLengths->end();
++primItr)
{
unsigned int localPrimLength;
if (primLength==0) localPrimLength=*primItr;
else localPrimLength=primLength;
glBegin(mode);
for(GLsizei primCount=0;primCount<*primItr;++primCount)
{
if ((primCount%localPrimLength)==0)
{
if (_normalData.binding==BIND_PER_PRIMITIVE) drawNormal(normalIndex++);
if (_colorData.binding==BIND_PER_PRIMITIVE) drawColor(colorIndex++);
if (secondaryColorBinding==BIND_PER_PRIMITIVE) drawSecondaryColor(secondaryColorIndex++);
if (fogCoordBinding==BIND_PER_PRIMITIVE) drawFogCoord(fogCoordIndex++);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_PRIMITIVE];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
}
if (_normalData.binding==BIND_PER_VERTEX) drawNormal(vindex);
if (_colorData.binding==BIND_PER_VERTEX) drawColor(vindex);
if (secondaryColorBinding==BIND_PER_VERTEX) drawSecondaryColor(vindex);
if (fogCoordBinding==BIND_PER_VERTEX) drawFogCoord(vindex);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_VERTEX];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
for(DrawTexCoordList::iterator texItr=drawTexCoordList.begin();
texItr!=drawTexCoordList.end();
++texItr)
{
(*(*texItr))(vindex);
}
if (drawTextCoord.valid()) (*drawTextCoord)(vindex);
if( useVertexAttrib )
{
(*drawVertexAttribZero)(vindex);
}
else
{
drawVertex(vindex);
}
++vindex;
}
glEnd();
}
break;
}
case(PrimitiveSet::DrawElementsUBytePrimitiveType):
{
if (primLength==0) primLength=primitiveset->getNumIndices();
const DrawElementsUByte* drawElements = static_cast<const DrawElementsUByte*>(primitiveset);
glBegin(mode);
unsigned int primCount=0;
for(DrawElementsUByte::const_iterator primItr=drawElements->begin();
primItr!=drawElements->end();
++primCount,++primItr)
{
if ((primCount%primLength)==0)
{
if (_normalData.binding==BIND_PER_PRIMITIVE) drawNormal(normalIndex++);
if (_colorData.binding==BIND_PER_PRIMITIVE) drawColor(colorIndex++);
if (secondaryColorBinding==BIND_PER_PRIMITIVE) drawSecondaryColor(secondaryColorIndex++);
if (fogCoordBinding==BIND_PER_PRIMITIVE) drawFogCoord(fogCoordIndex++);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_PRIMITIVE];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
}
unsigned int vindex=*primItr;
if (_normalData.binding==BIND_PER_VERTEX) drawNormal(vindex);
if (_colorData.binding==BIND_PER_VERTEX) drawColor(vindex);
if (secondaryColorBinding==BIND_PER_VERTEX) drawSecondaryColor(vindex);
if (fogCoordBinding==BIND_PER_VERTEX) drawFogCoord(vindex);
if ( extensions->isVertexProgramSupported() )
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_VERTEX];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
for(DrawTexCoordList::iterator texItr=drawTexCoordList.begin();
texItr!=drawTexCoordList.end();
++texItr)
{
(*(*texItr))(vindex);
}
if (drawTextCoord.valid()) (*drawTextCoord)(vindex);
if( useVertexAttrib )
{
(*drawVertexAttribZero)(vindex);
}
else
{
drawVertex(vindex);
}
}
glEnd();
break;
}
case(PrimitiveSet::DrawElementsUShortPrimitiveType):
{
if (primLength==0) primLength=primitiveset->getNumIndices();
const DrawElementsUShort* drawElements = static_cast<const DrawElementsUShort*>(primitiveset);
glBegin(mode);
unsigned int primCount=0;
for(DrawElementsUShort::const_iterator primItr=drawElements->begin();
primItr!=drawElements->end();
++primCount,++primItr)
{
if ((primCount%primLength)==0)
{
if (_normalData.binding==BIND_PER_PRIMITIVE) drawNormal(normalIndex++);
if (_colorData.binding==BIND_PER_PRIMITIVE) drawColor(colorIndex++);
if (secondaryColorBinding==BIND_PER_PRIMITIVE) drawSecondaryColor(secondaryColorIndex++);
if (fogCoordBinding==BIND_PER_PRIMITIVE) drawFogCoord(fogCoordIndex++);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_PRIMITIVE];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
}
unsigned int vindex=*primItr;
if (_normalData.binding==BIND_PER_VERTEX) drawNormal(vindex);
if (_colorData.binding==BIND_PER_VERTEX) drawColor(vindex);
if (secondaryColorBinding==BIND_PER_VERTEX) drawSecondaryColor(vindex);
if (fogCoordBinding==BIND_PER_VERTEX) drawFogCoord(vindex);
if (handleVertexAttributes)
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_VERTEX];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
for(DrawTexCoordList::iterator texItr=drawTexCoordList.begin();
texItr!=drawTexCoordList.end();
++texItr)
{
(*(*texItr))(vindex);
}
if (drawTextCoord.valid()) (*drawTextCoord)(vindex);
if( useVertexAttrib )
{
(*drawVertexAttribZero)(vindex);
}
else
{
drawVertex(vindex);
}
}
glEnd();
break;
}
case(PrimitiveSet::DrawElementsUIntPrimitiveType):
{
if (primLength==0) primLength=primitiveset->getNumIndices();
const DrawElementsUInt* drawElements = static_cast<const DrawElementsUInt*>(primitiveset);
glBegin(mode);
unsigned int primCount=0;
for(DrawElementsUInt::const_iterator primItr=drawElements->begin();
primItr!=drawElements->end();
++primCount,++primItr)
{
if ((primCount%primLength)==0)
{
if (_normalData.binding==BIND_PER_PRIMITIVE) drawNormal(normalIndex++);
if (_colorData.binding==BIND_PER_PRIMITIVE) drawColor(colorIndex++);
if (secondaryColorBinding==BIND_PER_PRIMITIVE) drawSecondaryColor(secondaryColorIndex++);
if (fogCoordBinding==BIND_PER_PRIMITIVE) drawFogCoord(fogCoordIndex++);
if ( extensions->isVertexProgramSupported() )
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_PRIMITIVE];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
}
unsigned int vindex=*primItr;
if (_normalData.binding==BIND_PER_VERTEX) drawNormal(vindex);
if (_colorData.binding==BIND_PER_VERTEX) drawColor(vindex);
if (secondaryColorBinding==BIND_PER_VERTEX) drawSecondaryColor(vindex);
if (fogCoordBinding==BIND_PER_VERTEX) drawFogCoord(vindex);
if ( extensions->isVertexProgramSupported() )
{
DrawVertexAttribList &list = drawVertexAttribMap[BIND_PER_VERTEX];
for( unsigned int i = 0; i < list.size(); ++i )
{
list[i]->applyAndIncrement();
}
}
for(DrawTexCoordList::iterator texItr=drawTexCoordList.begin();
texItr!=drawTexCoordList.end();
++texItr)
{
(*(*texItr))(vindex);
}
if (drawTextCoord.valid()) (*drawTextCoord)(vindex);
if( useVertexAttrib )
{
(*drawVertexAttribZero)(vindex);
}
else
{
drawVertex(vindex);
}
}
glEnd();
break;
}
default:
{
break;
}
}
}
}
}