Introduced dedicated VertexArrayStateList class to wrap up the VertexArrayState container with convinience methods to help initialize them.
Using the new VertexArrayStateList class fixed bug associated with setting new setTexCoord() array when a VertexArrayState is already assigned.
This commit is contained in:
@@ -546,6 +546,8 @@ void VertexArrayState::deleteVertexArrayObject()
|
||||
|
||||
void VertexArrayState::assignVertexArrayDispatcher()
|
||||
{
|
||||
if (_vertexArray.valid()) return;
|
||||
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (!_state->getUseVertexAttributeAliasing())
|
||||
{
|
||||
@@ -561,6 +563,8 @@ void VertexArrayState::assignVertexArrayDispatcher()
|
||||
|
||||
void VertexArrayState::assignNormalArrayDispatcher()
|
||||
{
|
||||
if (_normalArray.valid()) return;
|
||||
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (!_state->getUseVertexAttributeAliasing())
|
||||
{
|
||||
@@ -576,6 +580,8 @@ void VertexArrayState::assignNormalArrayDispatcher()
|
||||
|
||||
void VertexArrayState::assignColorArrayDispatcher()
|
||||
{
|
||||
if (_colorArray.valid()) return;
|
||||
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (!_state->getUseVertexAttributeAliasing())
|
||||
{
|
||||
@@ -591,6 +597,8 @@ void VertexArrayState::assignColorArrayDispatcher()
|
||||
|
||||
void VertexArrayState::assignSecondaryColorArrayDispatcher()
|
||||
{
|
||||
if (_secondaryColorArray.valid()) return;
|
||||
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (!_state->getUseVertexAttributeAliasing())
|
||||
{
|
||||
@@ -605,6 +613,8 @@ void VertexArrayState::assignSecondaryColorArrayDispatcher()
|
||||
|
||||
void VertexArrayState::assignFogCoordArrayDispatcher()
|
||||
{
|
||||
if (_fogCoordArray.valid()) return;
|
||||
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (!_state->getUseVertexAttributeAliasing())
|
||||
{
|
||||
@@ -622,8 +632,7 @@ void VertexArrayState::assignTexCoordArrayDispatcher(unsigned int numUnits)
|
||||
#ifdef OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE
|
||||
if (!_state->getUseVertexAttributeAliasing())
|
||||
{
|
||||
_texCoordArrays.clear();
|
||||
for(unsigned int i=0; i<numUnits; ++i)
|
||||
for(unsigned int i=_texCoordArrays.size(); i<numUnits; ++i)
|
||||
{
|
||||
_texCoordArrays.push_back( new TexCoordArrayDispatch(i) );
|
||||
}
|
||||
@@ -631,8 +640,7 @@ void VertexArrayState::assignTexCoordArrayDispatcher(unsigned int numUnits)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
_texCoordArrays.clear();
|
||||
for(unsigned int i=0; i<numUnits; ++i)
|
||||
for(unsigned int i=_texCoordArrays.size(); i<numUnits; ++i)
|
||||
{
|
||||
VAS_NOTICE<<"VertexArrayState::VertexArrayState::assignTexCoordArrayDispatcher() _state->getTexCoordAliasList()[i]._location="<<_state->getTexCoordAliasList()[i]._location<<std::endl;
|
||||
_texCoordArrays.push_back( new VertexAttribArrayDispatch(_state->getTexCoordAliasList()[i]._location) );
|
||||
@@ -642,8 +650,7 @@ void VertexArrayState::assignTexCoordArrayDispatcher(unsigned int numUnits)
|
||||
|
||||
void VertexArrayState::assignVertexAttribArrayDispatcher(unsigned int numUnits)
|
||||
{
|
||||
_vertexAttribArrays.clear();
|
||||
for(unsigned int i=0; i<numUnits; ++i)
|
||||
for(unsigned int i=_vertexAttribArrays.size(); i<numUnits; ++i)
|
||||
{
|
||||
_vertexAttribArrays.push_back( new VertexAttribArrayDispatch(i) );
|
||||
}
|
||||
@@ -759,3 +766,103 @@ void VertexArrayState::dirty()
|
||||
setRequiresSetArrays(true);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
VertexArrayStateList::VertexArrayStateList():
|
||||
_array(DisplaySettings::instance()->getMaxNumberOfGraphicsContexts())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
VertexArrayStateList& VertexArrayStateList::operator = (const VertexArrayStateList& rhs)
|
||||
{
|
||||
if (&rhs==this) return *this;
|
||||
|
||||
_array = rhs._array;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void VertexArrayStateList::assignAllDispatchers()
|
||||
{
|
||||
for(Array::iterator itr = _array.begin();
|
||||
itr != _array.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->valid()) (*itr)->assignAllDispatchers();
|
||||
}
|
||||
}
|
||||
|
||||
void VertexArrayStateList::assignVertexArrayDispatcher()
|
||||
{
|
||||
for(Array::iterator itr = _array.begin();
|
||||
itr != _array.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->valid()) (*itr)->assignVertexArrayDispatcher();
|
||||
}
|
||||
}
|
||||
|
||||
void VertexArrayStateList::assignNormalArrayDispatcher()
|
||||
{
|
||||
for(Array::iterator itr = _array.begin();
|
||||
itr != _array.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->valid()) (*itr)->assignNormalArrayDispatcher();
|
||||
}
|
||||
}
|
||||
|
||||
void VertexArrayStateList::assignColorArrayDispatcher()
|
||||
{
|
||||
for(Array::iterator itr = _array.begin();
|
||||
itr != _array.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->valid()) (*itr)->assignColorArrayDispatcher();
|
||||
}
|
||||
}
|
||||
|
||||
void VertexArrayStateList::assignSecondaryColorArrayDispatcher()
|
||||
{
|
||||
for(Array::iterator itr = _array.begin();
|
||||
itr != _array.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->valid()) (*itr)->assignSecondaryColorArrayDispatcher();
|
||||
}
|
||||
}
|
||||
|
||||
void VertexArrayStateList::assignFogCoordArrayDispatcher()
|
||||
{
|
||||
for(Array::iterator itr = _array.begin();
|
||||
itr != _array.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->valid()) (*itr)->assignFogCoordArrayDispatcher();
|
||||
}
|
||||
}
|
||||
|
||||
void VertexArrayStateList::assignTexCoordArrayDispatcher(unsigned int numUnits)
|
||||
{
|
||||
for(Array::iterator itr = _array.begin();
|
||||
itr != _array.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->valid())
|
||||
{
|
||||
(*itr)->assignTexCoordArrayDispatcher(numUnits);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VertexArrayStateList::assignVertexAttribArrayDispatcher(unsigned int numUnits)
|
||||
{
|
||||
for(Array::iterator itr = _array.begin();
|
||||
itr != _array.end();
|
||||
++itr)
|
||||
{
|
||||
if (itr->valid()) (*itr)->assignVertexAttribArrayDispatcher(numUnits);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user