# Help me please - heigh map problem

Im trying to load a height map and put everything in a matrix… but its not working, nothing its drawn.

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++;
}
``````

}
}

{
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();
}