Height Map

void GLClass::GLDrawHeightField (Object *GLObjTmp, int GLwire)
{
int X, Y;
float x, y, z;
_HeightField *HF;
CObjects *CObj;
int step_size, width, height, color;
CTransformations *CTrans;

glPushMatrix ();

CTrans = new CTransformations;
CTrans->ExecuteObjTranslations (GLObjTmp);

HF = new _HeightField;
HF = (_HeightField *)GLObjTmp->ObjProperties;
CObj = new CObjects;

step_size = HF->step_size;

width = HF->width;
height = HF->height;

if (!HF->image)
return;

if (GLwire)
{
if (GLObjTmp->Selected)
glColor3f (1.0, 1.0, 0.0);
else
glColor3f (1.0, 1.0, 1.0);
}

glBegin (GL_QUADS);

for (X = 0; X < width; X += step_size)
for (Y = 0; Y < height; Y += step_size)
{
x = X;
y = CObj->HF_Height (HF, X, Y);
z = Y;

if (!GLwire)
 {
  //Texture Stuff
  color = CObj-&gt;HF_SetVertexColor (HF, x, z);
  glColor3f (color, color, 0.0);
 }

glVertex3d (x, y, z);

x = X;
y = CObj-&gt;HF_Height (HF, X, Y + step_size);
z = Y + step_size;

if (!GLwire)
 {
  //Texture Stuff
  color = CObj-&gt;HF_SetVertexColor (HF, x, z);
  glColor3f (color, color, 0.0);
 }

glVertex3d (x, y, z);

x = X + step_size;
y = CObj-&gt;HF_Height (HF, X + step_size, Y + step_size);
z = Y + step_size;

if (!GLwire)
 {
  //Texture Stuff
  color = CObj-&gt;HF_SetVertexColor (HF, x, z);
  glColor3f (color, color, 0.0);
 }

glVertex3d (x, y, z);

x = X + step_size;
y = CObj-&gt;HF_Height (HF, X + step_size, Y);
z = Y;

if (!GLwire)
 {
  //Texture Stuff
  color = CObj-&gt;HF_SetVertexColor (HF, x, z);
  glColor3f (color, color, 0.0);
 }

glVertex3d (x, y, z);

}
glEnd();
glPopMatrix();
}

i know it is long, but i need help please! the code above draws my height field that is loaded. that parts works sortof. the problem i have is it will not shoe th 3d perspective view. it will shpow ortho, bbut not perspective…why? also, if i have a height map 1024x1024 what is appropriate to scale it down to?

You don’t show your projection matrix setup, so it’s hard to answer your question. Most likely you are drawing it outside the viewing area of your perspective view.

Make sure that for your perspective view, the near clip plane is greater than 0.

One other brief comment. I noticed you were using quads. Have you done anything to ensure that the vertices of your quads will all be planar? If they aren’t, the behavior will be undefined. It’s usually better to use triangles or triangle strips for a heightmap.