Here is a sample terrain map that I used in my engine.
Load this as a raw file - but you will have to smooth it in a paint program or something. The JPG format causes a lot of loss and the BMP was too large to attach.
Load as a RAW file with no header. The size is 480x480 - to get along with this board's limit of 640x480.
Code:
bool Terrain::readRawFile(std::string fileName)
{
// A height for each vertex
std::vector<BYTE> in( _numVertices );
std::ifstream inFile(fileName.c_str(), std::ios_base::binary);
if( inFile == 0 )
return false;
inFile.read((char*)&in[0],
in.size());
inFile.close();
// copy BYTE vector to int vector
_heightmap.resize( _numVertices );
for(int i = 0; i < in.size(); i++)
_heightmap[i] = in[i];
return true;
}
That will load the raw file. NumVertices is the number of vertices in your terrain (hence if you use a 256x256 heightmap it will be 256*256)
The first jpg is height data - convert it to raw format and save.
The second jpg is the color or texture data. Simply compute the necessary u and v coords per vertex and set this as the texture.
The u and v increments will be 1/(sizex) and 1/(sizey).
Several terrain generation programs:
http://www.ridgecrest.ca.us/~jslayton/terrain.html
or simply use a paint program and convert image to greyscale. White is highest, black is lowest - paint your terrain...smooth a couple of times and wallah...terrain.