HeightMap Terrain demo using SDL/OpenGL

Hi all,
I recently bought the OpenGL Game Programming book and thought I
would try and port one of the demos ( Chapter 8 terrain demo actually )
to SDL.
I have loaded the HeightMap greyscale bitmap into a surface and I need
to access the pixel information so I can store it in an array for later
access. The original code is as follows…

void InitializeTerrain()
{
// loop through all of the heightfield points, calculating
// the coordinates for each point
for (int z = 0; z < MAP_Z; z++)
{
for (int x = 0; x < MAP_X; x++)
{
terrain[x][z][0] = float(x)MAP_SCALE;
terrain[x][z][1] = (float)imageData[(z
MAP_Z+x)*3]; <----!!!
terrain[x][z][2] = -float(z)*MAP_SCALE;
}
}
}

where imageData is defined as…
unsigned char* imageData; // the map image data

and terrain is defined as
////// Terrain Data
float terrain[MAP_X][MAP_Z][3]; // heightfield terrain data

The line marked as <----!!!, in the code above, is the one I am not
sure how to convert so that I can use pixels attribute of the SDLSurface .

Any hints of how to rewrite that one line would be great.

BTW are there better techniques of creating Terrain using OpenGL. Are
there any other SDL/OpenGL demos out there that are being used in a game
context.

Thanks in advance for any hints.

L8R,

Dominique
http://www.DelphiGamer.com