diff --git a/include/osg/State b/include/osg/State index 9bd12b1b0..d05f51d71 100644 --- a/include/osg/State +++ b/include/osg/State @@ -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.*/ diff --git a/src/osg/GeoSet_ogl.cpp b/src/osg/GeoSet_ogl.cpp index 015b86c90..5156922cc 100644 --- a/src/osg/GeoSet_ogl.cpp +++ b/src/osg/GeoSet_ogl.cpp @@ -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 ); diff --git a/src/osg/Geometry.cpp b/src/osg/Geometry.cpp index a368b8f69..ad4d1025e 100644 --- a/src/osg/Geometry.cpp +++ b/src/osg/Geometry.cpp @@ -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.