I am trying to create terrain which takes height values from txt file .
During my search I realized that generally the terrains are created from bmp files or another kind of picture taking values from pixels. I read height values from file into a 2d array.
void File(){
FILE* file = fopen("data.txt", "r"); // data.txt opened with read only mode to get heights
int i,j;
for (i = 0; i < 17; i++){
for (j = 0; j < 21; j++){
fscanf(file, "%d", &data[i][j]);
}
}
fclose(file);
}
and then load these values to vertex to create triangle.
But there are triangles everywhere when I change the x y z
values .
The intended project is to create a terrain.
Is there a special way or code to create terrain by using just height values from a txt file?
OpenGL renders primitives like triangles and triangle strips. You'll need to convert your terrain heightmap into primitives that OpenGL understands.
Perhaps this tutorial found by a quick google search can help you.
http://www.codeproject.com/Articles/14154/OpenGL-Terrain-Generation-An-Introduction