textured heightfield problem

i am trying to create a textured heightfield
here is the code:
int mapX = 257;
int mapZ = 257;
float mapScale = 200.0;
float waterHeight = 154.0f;
bool waterDir = true;

float terrainArray[mapX][mapZ][3];

int h,w;

for ( h = 0; h < HEIGHT; h++) {
for ( w = 0; w < WIDTH; w++) {
terrainArray[w][h][0] = float(w) * mapScale;
terrainArray[w][h][1] = (float)terrain_hf[(h*WIDTH)+w];
terrainArray[w][h][2] = float(h) * mapScale;
}
}

for ( h = 0; h < HEIGHT-1; h++) {
glBegin(GL_TRIANGLE_STRIP);
for ( w = 0; w < WIDTH-1; w++) {
// glColor3f(terrainArray[w][h][0]/255.0f,terrainArray[w][h][1]/255.0f,terrainArray[w][h][2]/255.0f);
// cerr<<“here”<<endl;
glVertex3f(terrainArray[w][h][0],terrainArray[w][h][1],terrainArray[w][h][2]);

  //       glColor3f(terrainArray[w+1][h][0]/255.0f,terrainArray[w+1][h][1]/255.0f,terrainArray[w+1][h][2]/255.0f);
  glVertex3f(terrainArray[w+1][h][0],terrainArray[w+1][h][1],terrainArray[w+1][h][2]);
  
  //       glColor3f(terrainArray[w][h+1][0]/255.0f,terrainArray[w][h+1][1]/255.0f,terrainArray[w][h+1][2]/255.0f);
  glVertex3f(terrainArray[w][h+1][0],terrainArray[w][h+1][1],terrainArray[w][h+1][2]);
  
  //       glColor3f(terrainArray[w+1][h+1][0]/255.0f,terrainArray[w+1][h+1][1]/255.0f,terrainArray[w+1][h+1][2]/255.0f);
  glVertex3f(terrainArray[w+1][h+1][0],terrainArray[w+1][h+1][1],terrainArray[w+1][h+1][2]);
}
glEnd();

}

glFlush();
glutSwapBuffers();

this displays nothing does anyone know what a possible fix maybe or what my problem is?
Incus

I believe that you should only be passing two vertices in every loop instead of four vertices since you are using triangle strips. Also, it looks like your setting the Z value of the terrain array to the [x][y][1] component. Then when you render, you’re switching the y and z components.

Pat

[This message has been edited by Pat (edited 09-17-2002).]