Help me please - height map loading

Im trying to use a height map loader, but its not working, whats the problem with this code? Help me please

GLfloat vertices_x[6][MAP_SIZEMAP_SIZE];
GLfloat vertices_y[6][MAP_SIZE
MAP_SIZE];
GLfloat vertices_z[6][MAP_SIZE*MAP_SIZE];

GLfloat Height(BYTE *pHeightMap, int X, int Y) //WORKS FINE
{
int x = X % MAP_SIZE;
int y = Y % MAP_SIZE;
if(!pHeightMap) return 0;
return pHeightMap[x + (y * MAP_SIZE)];
}

void LoadRawFile(LPSTR strName, int nSize, BYTE *pHeightMap) //WORKS FINE
{
FILE *pFile = NULL;
pFile = fopen( strName, “rb” );
if ( pFile == NULL )
{
MessageBox(NULL, “Mapa nao encontrado.”, “Erro”, MB_OK);
return;
}
fread( pHeightMap, 1, nSize, pFile );
int result = ferror( pFile );
if (result)
{
MessageBox(NULL, “Erro ao carregar Mapa de terreno.”, “Erro”, MB_OK);
}
fclose(pFile);
}

void buildVertex(BYTE pHeightMap[],GLint STEP_SIZE,int QUAD_ID) //POSSIBLE PROBLEM
{
int X=0,Y=0;
int looper;
if(!pHeightMap) return;
for ( X = 0; X < MAP_SIZE; X += STEP_SIZE ) {
for ( Y = 0; Y < MAP_SIZE; Y += STEP_SIZE )
{
vertices_x[0][looper]=X;
vertices_y[0][looper]=Height(pHeightMap, X, Y )*ELEVATION;
vertices_z[0][looper]=Y;

  	vertices_x[1][looper]=X;
  	vertices_y[1][looper]=Height(pHeightMap, X, Y + STEP_SIZE)*ELEVATION;
  	vertices_z[1][looper]=Y + STEP_SIZE;

  	vertices_x[2][looper]=X + STEP_SIZE;
  	vertices_y[2][looper]=Height(pHeightMap, X + STEP_SIZE, Y+ STEP_SIZE) *ELEVATION;
  	vertices_z[2][looper]=Y + STEP_SIZE;

  	vertices_x[3][looper]=X + STEP_SIZE;
  	vertices_y[3][looper]=Height(pHeightMap, X + STEP_SIZE, Y )*ELEVATION;
  	vertices_z[3][looper]=Y;

  	vertices_x[4][looper]=X;
  	vertices_y[4][looper]=Height(pHeightMap, X, Y )*ELEVATION;
  	vertices_z[4][looper]=Y;

  	vertices_x[5][looper]=X + STEP_SIZE;
  	vertices_y[5][looper]=Height(pHeightMap, X + STEP_SIZE, Y + STEP_SIZE) *ELEVATION;
  	vertices_z[5][looper]=Y + STEP_SIZE;
  	
  	looper++;
  }

}
}

void drawQuad(int QUAD_ID,int TEX_ID,int AUTO_GEN,int START_POSIx,int START_POSIz) //POSSIBLE PROBLEM
{
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, texture[3]);
glBegin(GL_TRIANGLES);
int i;
for(i=0;i<=MAP_SIZE*MAP_SIZE;i++) {
glTexCoord2f(0,0); glVertex3f(vertices_x[0][i],vertices_y[0][i],vertices_z[0][i]);
glTexCoord2f(1,0); glVertex3f(vertices_x[1][i],vertices_y[1][i],vertices_z[1][i]);
glTexCoord2f(1,1); glVertex3f(vertices_x[2][i],vertices_y[2][i],vertices_z[2][i]);
glTexCoord2f(0,1); glVertex3f(vertices_x[3][i],vertices_y[3][i],vertices_z[3][i]);
glTexCoord2f(0,0); glVertex3f(vertices_x[4][i],vertices_y[4][i],vertices_z[4][i]);
glTexCoord2f(1,1); glVertex3f(vertices_x[5][i],vertices_y[5][i],vertices_z[5][i]);
}
glEnd();
glPopMatrix();
}

void loadQuad(LPSTR strName,int QUAD_ID) //POSSIBLE PROBLEM
{
LoadRawFile(strName, MAP_SIZE * MAP_SIZE, g_HeightMap);
buildVertex(g_HeightMap,15,QUAD_ID);
}

looper is not initialiazed. (of course there might be other problems)

Using a debugger would really help you…

[This message has been edited by Gorg (edited 01-22-2002).]