Original Post
glBindTexture(GL_TEXTURE_2D, groundTexture);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
for (int z = 0; z < Size - 1; z++)
{
glBegin(GL_TRIANGLE_STRIP);
for (int x = 0; x < Size; x++)
{
// render two vertices of the strip at once
float scaledHeight = heightmap[z * Size + x] / ScaleFactor;
float nextScaledHeight = heightmap[(z + 1)* Size + x] / ScaleFactor;
float color = 0.5f + 0.5f * scaledHeight / MaxHeight;
float nextColor = 0.5f + 0.5f * nextScaledHeight / MaxHeight;
glColor3f(color, color, color);
glTexCoord2f((GLfloat)x/Size*8, (GLfloat)z/Size*8);
glVertex3f(static_cast<GLfloat>(x - Size/2), scaledHeight, static_cast<GLfloat>(z - Size/2));
glColor3f(nextColor, nextColor, nextColor);
glTexCoord2f((GLfloat)x/Size*8, (GLfloat)(z+1)/Size*8);
glVertex3f(static_cast<GLfloat>(x - Size/2), nextScaledHeight, static_cast<GLfloat>(z + 1 - Size/2));
}
glEnd();
}