glPushMatrix( );
glTranslatef( halfWidth, halfHeight, 127.0 );
glRotatef( rotX, 1.0, 0.0, 0.0 );
glRotatef( rotY, 0.0, 1.0, 0.0 );
glTranslatef( -halfWidth, -halfHeight, -127.0 );
glBegin( GL_TRIANGLES );
glColor3f( 0.5, 0.5, 0.5 );
for( y = 0 ; y < ( height2 - 1 ) ; y++ )
{
for( x = 0 ; x < ( width2 - 1 ) ; x++ )
{
v[0][0] = x;
v[0][1] = y;
v[0][2] = image[y * nc + x];
v[1][0] = x;
v[1][1] = y + 1;
v[1][2] = image[( y + 1 ) * nc + x];
v[2][0] = x + 1;
v[2][1] = y;
v[2][2] = image[y * nc + ( x + 1 )];
calcNormal( v, normal );
glNormal3fv( normal );
glVertex3fv( v[0] );
glVertex3fv( v[1] );
glVertex3fv( v[2] );
v[0][0] = x;
v[0][1] = y + 1;
v[0][2] = image[( y + 1 ) * nc + x];
v[1][0] = x + 1;
v[1][1] = y;
v[1][2] = image[y * nc + ( x + 1 )];
v[2][0] = x + 1;
v[2][1] = y + 1;
v[2][2] = image[( y + 1 ) * nc + ( x + 1 )];
calcNormal( v, normal );
glNormal3fv( normal );
glVertex3fv( v[0] );
glVertex3fv( v[1] );
glVertex3fv( v[2] );
} // End for( x = 0 ; x < width2 ; x++ )
} // End for( y = 0 ; y < ( height2 - 1 ) ; y++ )
glEnd( );
glPopMatrix( );