From e767db91823b05c919c98067435fbae639c31481 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 2 Jan 2002 10:53:20 +0000 Subject: [PATCH] Moved the glShadeModel(FLAT/SMOOTH) outside of the primtitive inner loop to reduce the amount state changes incurred when using FLAT_ primtives. --- src/osg/GeoSet_ogl.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/osg/GeoSet_ogl.cpp b/src/osg/GeoSet_ogl.cpp index ee5f47ac4..46a439aa4 100644 --- a/src/osg/GeoSet_ogl.cpp +++ b/src/osg/GeoSet_ogl.cpp @@ -291,6 +291,13 @@ void GeoSet::draw_alternate_path( void ) return; } + if( _flat_shaded_skip ) + { + #ifdef DO_SHADING + glShadeModel( GL_FLAT ); + #endif + } + for( i = 0; i < _numprims; i++ ) { if( _color_binding == BIND_PERPRIM ) @@ -310,9 +317,6 @@ void GeoSet::draw_alternate_path( void ) if( _flat_shaded_skip ) { - #ifdef DO_SHADING - glShadeModel( GL_FLAT ); - #endif glBegin( (GLenum)_oglprimtype ); for( j = 0; j < _primLengths[i]; j++ ) { @@ -349,10 +353,6 @@ void GeoSet::draw_alternate_path( void ) glArrayElement( ai++ ); } glEnd(); - - #ifdef DO_SHADING - glShadeModel( GL_SMOOTH ); - #endif } else @@ -394,6 +394,13 @@ void GeoSet::draw_alternate_path( void ) } index += _primLengths[i]; } + + if( _flat_shaded_skip ) + { + #ifdef DO_SHADING + glShadeModel( GL_SMOOTH ); + #endif + } } else // POINTS, LINES, TRIANGLES, QUADS {