Any method to texture map a tessellated polygon?

Hi there,

Could someone tell me how to do texture mapping on a tessellated polygon, especially the one with a hole in it?

I have tried two methods:

  1. Override the callback function of gluTessVertex(), and pass the vertices coordinates as well as texture coordinates as the argument(which is in void*). However, the system crashed!

  2. Use glTexGen() and specify two planes(by specifying the coefficients of ax+by+cz+d=0) and let OpenGL generate the texture coordinates for me. However, the textures are incorrectly mapped and when I move the camera position/angle(by using gluLookAt()), the textures are “floating” on the polygon.

How can I do that? Can someone tell me what’s wrong with my methods? Any links of how to do this in detail, or with examples? Thank you very much in advance!