less repetition of vertices for triangle strip

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1268 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2012-04-28 16:35:39 +00:00
parent 21268d0831
commit 93e05f42de

View File

@ -1883,28 +1883,30 @@ void FGAPIENTRY glutSolidTorus( double dInnerRadius, double dOuterRadius, GLint
for( i=0; i<nSides; i++ )
{
int offset;
int ioff = 3;
if (i==nSides-1)
ioff = -i*3;
glBegin( GL_TRIANGLE_STRIP );
for( j=0; j<nRings; j++ )
{
int offset = 3 * ( j * nSides + i ) ;
glNormal3fv( normal + offset );
glVertex3fv( vertex + offset );
glNormal3fv( normal + offset + ioff );
glVertex3fv( vertex + offset + ioff );
offset = 3 * ( ((j+1)%nRings) * nSides + i) ;
offset = 3 * ( j * nSides + i ) ;
glNormal3fv( normal + offset );
glVertex3fv( vertex + offset );
glNormal3fv( normal + offset + ioff );
glVertex3fv( vertex + offset + ioff );
}
/* repeat first to close off shape */
offset = 3 * i;
glNormal3fv( normal + offset );
glVertex3fv( vertex + offset );
glNormal3fv( normal + offset + ioff );
glVertex3fv( vertex + offset + ioff );
glEnd();
}
free ( vertex ) ;
free ( normal ) ;
}