Drape a bitmap on a surface

Need to drape a bitmap on a height surface composed of points. Any ideas for opengl functions available, links …
(The bitmap is a scanned map that I want draped on a height surface).

Thanks Jakob

As far as I know you can’t just ‘drape’ a texture over something. A texture isn’t a table cloth. The only way you’re going to be able to texture your surface is to tesselate it into triangles and do texture mapping of some sort.

-SirKnight

Maybe glTexGen is what you need.

If your height map uses z for height and x and y are in the intervals [0, w] and [0, h], respectively, then this code would generate texture coordinates for your height map:

glEnable (GL_TEXTURE_2D) ;
glBindTexture (GL_TEXTURE_2D, bitmapTex) ;

float w = … ;
float h = … ;

glEnable (GL_TEXTURE_GEN_S) ;
glEnable (GL_TEXTURE_GEN_T) ;

glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;
glTexGeni (GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR) ;

float splane[4] = { 1.0f/w, 0, 0, 0 } ;
float tplane[4] = { 0, 1.0f/h, 0, 0 } ;
glTexGenfv (GL_S, GL_OBJECT_PLANE, splane) ;
glTexGenfv (GL_T, GL_OBJECT_PLANE, tplane) ;

// Draw your height field here. I use a single quad.
glBegin (GL_QUADS) ;
glVertex3f (0, 0, 0) ;
glVertex3f (w, 0, 0) ;
glVertex3f (w, h, 0) ;
glVertex3f (0, h, 0) ;
glEnd() ;

/Jonas