//needed here for blended shading model at each redraw
glShadeModel(GL_SMOOTH);
if(texture){
//uses predefined texture from setParams()
glBindTexture(GL_TEXTURE_2D, textures[1]);
//turns on texturing
glEnable(GL_TEXTURE_2D);
}
glEnable(GL_COLOR_MATERIAL);
//select the current color according to color scheme
if (colorScheme == DARK) glColor3f(0.25f,0.25f,0.25f);
if (colorScheme == LIGHT) glColor3f(0.8f,0.8f,0.8f);
if (colorScheme == MIDDLE) glColor3f(0.4f,0.4f,0.4f);
//draw "terrain" object then put texture on it
start = FSIZE/8;
end = FSIZE*7/8;
cent = float(FSIZE)/2.0f;
glPushMatrix();
glTranslatef(-cent,-cent,-10.5);
for(i=start;i<end;++i){
glBegin(GL_QUAD_STRIP);
for(j=start;j<end;++j){
//set the normals for the surface rendered
glNormal3f(normsX[i][j],normsY[i][j],normsZ[i][j]);
//sets the current texture coordinates
glTexCoord2f(field[i][j]*b + a, field[i][j]*b + a);
//vertex to be rendered
glVertex3f(float(i),float(j),field[i][j]);
//repeat
glNormal3f(normsX[i+1][j],normsY[i+1][j],normsZ[i+1][j]);
glTexCoord2f(field[i+1][j]*b + a, field[i+1][j]*b + a);
glVertex3f(float(i+1),float(j),field[i+1][j]);
}
glEnd();
}
glDisable(GL_TEXTURE_2D);