a “image warp” effect stretch the 4 points(left,right,top,bottom) of a 2D image to diffrent localtion,so the image is stretched to 4 different directions. I do my work using below code firstly:
glBegin(GL_QUADS);
But it fail,because the quad is divided into 2 triangles.I also test the Q texcoord from the NVSdk,but it require the top 2 vertexes and bottom 2 vertexes are horizontal(y0==y3,y1==y2),but I want my program can place the 4 vertexes anywhere,so how to do?
Some problem else:I found the R parameter is always 0 in NVIDIA sdk’s code(glTexCoord4f(s,t,0,q)),so what’s the use of it?Is it the key to solve my problem?
You don’t need to seta “r” component as that is only used in Cube/3D texture lookups.
You are going to calculate a “q” coordinate for each vertex to prevent the texture distortion. This will involve figuring out the texture rate of change at each vertex. I cannot help with this but I am sure there exists on google people with similar problems (with a generic solution)
He already claimed he read the q coordinate article.
The real solution is to tesselate your quad into 4096 quads, a mesh with 64 quads to a side, and interpolate your texture coordinates (and vertex coordinates) into this mesh. That will minimize distortion. If you want less distortion, use higher tesselation.