Added State::disableTexCoordPointersAboveAndIncluding( unit ) method so that
all unsed texture units can be turned off simply within Drawables such as Geometry and GeoSet. This can be used to prevent bleed of arrays from one object to the next - which can cause crashes.
This commit is contained in:
parent
6a2aa35c26
commit
db892e6bfe
@ -356,6 +356,22 @@ class SG_EXPORT State : public Referenced
|
||||
}
|
||||
}
|
||||
|
||||
inline void disableTexCoordPointersAboveAndIncluding( unsigned int unit )
|
||||
{
|
||||
while (unit<_texCoordArrayList.size())
|
||||
{
|
||||
EnabledArrayPair& eap = _texCoordArrayList[unit];
|
||||
if (eap._enabled)
|
||||
{
|
||||
if (setClientActiveTextureUnit(unit))
|
||||
{
|
||||
eap._enabled = false;
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
}
|
||||
++unit;
|
||||
}
|
||||
}
|
||||
|
||||
/** set the current tex coord array texture unit, return true if selected, false if selection failed such as when multitexturing is not supported.
|
||||
* note, only updates values that change.*/
|
||||
|
@ -96,7 +96,7 @@ void GeoSet::draw_fast_path( State& state )
|
||||
|
||||
state.disableNormalPointer();
|
||||
state.disableColorPointer();
|
||||
state.disableTexCoordPointer(0);
|
||||
state.disableTexCoordPointersAboveAndIncluding(0);
|
||||
state.setVertexPointer(3, GL_FLOAT, 0,_coords);
|
||||
// glDisableClientState( GL_COLOR_ARRAY );
|
||||
// glDisableClientState( GL_NORMAL_ARRAY );
|
||||
@ -109,6 +109,7 @@ void GeoSet::draw_fast_path( State& state )
|
||||
state.disableNormalPointer();
|
||||
state.disableColorPointer();
|
||||
state.setTexCoordPointer(0, 2, GL_FLOAT, 0, (GLfloat *)_tcoords );
|
||||
state.disableTexCoordPointersAboveAndIncluding(1);
|
||||
state.setVertexPointer(3, GL_FLOAT, 0,_coords);
|
||||
// glDisableClientState( GL_COLOR_ARRAY );
|
||||
// glDisableClientState( GL_NORMAL_ARRAY );
|
||||
@ -120,7 +121,7 @@ void GeoSet::draw_fast_path( State& state )
|
||||
|
||||
case (N_ON|V_ON) :
|
||||
state.disableColorPointer();
|
||||
state.disableTexCoordPointer(0);
|
||||
state.disableTexCoordPointersAboveAndIncluding(0);
|
||||
state.setVertexPointer(3, GL_FLOAT, 0,_coords);
|
||||
state.setNormalPointer( GL_FLOAT, 0, (GLfloat *)_normals );
|
||||
// glDisableClientState( GL_COLOR_ARRAY );
|
||||
@ -135,6 +136,7 @@ void GeoSet::draw_fast_path( State& state )
|
||||
state.disableColorPointer();
|
||||
state.setNormalPointer( GL_FLOAT, 0, (GLfloat *)_normals );
|
||||
state.setTexCoordPointer(0, 2, GL_FLOAT, 0, (GLfloat *)_tcoords );
|
||||
state.disableTexCoordPointersAboveAndIncluding(1);
|
||||
state.setVertexPointer(3, GL_FLOAT, 0,_coords);
|
||||
// glDisableClientState( GL_COLOR_ARRAY );
|
||||
// glEnableClientState( GL_NORMAL_ARRAY );
|
||||
@ -147,7 +149,7 @@ void GeoSet::draw_fast_path( State& state )
|
||||
|
||||
case (C_ON|V_ON) :
|
||||
state.disableNormalPointer();
|
||||
state.disableTexCoordPointer(0);
|
||||
state.disableTexCoordPointersAboveAndIncluding(0);
|
||||
state.setColorPointer( 4, GL_FLOAT, 0, (GLfloat *)_colors );
|
||||
state.setVertexPointer(3, GL_FLOAT, 0,_coords);
|
||||
// glEnableClientState( GL_COLOR_ARRAY );
|
||||
@ -162,6 +164,7 @@ void GeoSet::draw_fast_path( State& state )
|
||||
state.disableNormalPointer();
|
||||
state.setColorPointer( 4, GL_FLOAT, 0, (GLfloat *)_colors );
|
||||
state.setTexCoordPointer(0, 2, GL_FLOAT, 0, (GLfloat *)_tcoords );
|
||||
state.disableTexCoordPointersAboveAndIncluding(1);
|
||||
state.setVertexPointer(3, GL_FLOAT, 0,_coords);
|
||||
// glEnableClientState( GL_COLOR_ARRAY );
|
||||
// glColorPointer( 4, GL_FLOAT, 0, (GLfloat *)_colors );
|
||||
@ -173,7 +176,7 @@ void GeoSet::draw_fast_path( State& state )
|
||||
break;
|
||||
|
||||
case (C_ON|N_ON|V_ON) :
|
||||
state.disableTexCoordPointer(0);
|
||||
state.disableTexCoordPointersAboveAndIncluding(0);
|
||||
state.setNormalPointer( GL_FLOAT, 0, (GLfloat *)_normals );
|
||||
state.setColorPointer( 4, GL_FLOAT, 0, (GLfloat *)_colors );
|
||||
state.setVertexPointer(3, GL_FLOAT, 0,_coords);
|
||||
@ -190,6 +193,7 @@ void GeoSet::draw_fast_path( State& state )
|
||||
state.setNormalPointer( GL_FLOAT, 0, (GLfloat *)_normals );
|
||||
state.setColorPointer( 4, GL_FLOAT, 0, (GLfloat *)_colors );
|
||||
state.setTexCoordPointer(0, 2, GL_FLOAT, 0, (GLfloat *)_tcoords );
|
||||
state.disableTexCoordPointersAboveAndIncluding(1);
|
||||
state.setVertexPointer(3, GL_FLOAT, 0,_coords);
|
||||
// glEnableClientState( GL_COLOR_ARRAY );
|
||||
// glColorPointer( 4, GL_FLOAT, 0, (GLfloat *)_colors );
|
||||
@ -305,9 +309,10 @@ void GeoSet::draw_alternate_path( State& state )
|
||||
// glEnableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
// glTexCoordPointer( 2, GL_FLOAT, 0, _tcoords );
|
||||
state.setTexCoordPointer( 0, 2, GL_FLOAT, 0, _tcoords );
|
||||
state.disableTexCoordPointersAboveAndIncluding(1);
|
||||
}
|
||||
else
|
||||
state.disableTexCoordPointer(0);
|
||||
state.disableTexCoordPointersAboveAndIncluding(0);
|
||||
// glDisableClientState( GL_TEXTURE_COORD_ARRAY );
|
||||
|
||||
// glEnableClientState( GL_VERTEX_ARRAY );
|
||||
|
@ -48,7 +48,8 @@ void Geometry::drawImmediateMode(State& state)
|
||||
state.setVertexPointer(3,GL_FLOAT,0,_vertexArray->dataPointer());
|
||||
|
||||
// set up texture coordinates.
|
||||
for(unsigned int i=0;i<_texCoordList.size();++i)
|
||||
unsigned int i;
|
||||
for(i=0;i<_texCoordList.size();++i)
|
||||
{
|
||||
Array* array = _texCoordList[i].get();
|
||||
if (array)
|
||||
@ -56,6 +57,7 @@ void Geometry::drawImmediateMode(State& state)
|
||||
else
|
||||
state.disableTexCoordPointer(i);
|
||||
}
|
||||
state.disableTexCoordPointersAboveAndIncluding(i);
|
||||
|
||||
|
||||
// set up normals.
|
||||
|
Loading…
Reference in New Issue
Block a user