Depending on how the data looks in the heightmap, say its in the format of vertex/height.
You could read in a line, say its
v 1.7/2.1/3.7 h 10
store off the vertex and translate that vertex up 10 (height).
Repeat for each vertex and connect them with faces.
If it's just height values then you could substitue in arbitrary verticies for each height value.
I.E.
heightmap:
h 10
h 20
h 30
Then as a function:
void generateTerrain(int length, int width)
{
for(;length>= 0; --length)
{
for(; width >= 0; --width)
{
//read line from file
//store the height in a temp hieght variable
//createVertex(length, width, height);
//store this vertex somewhere for later
}
}
}
There are probably way more efficient ways of doing that, but for simple terrain generation that just popped in my head :)