pango

12-10-2004, 04:04 AM

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);

glTexCoord2f(0,0);glVertex2f(x0,y0);

glTexCoord2f(0,1);glVertex2f(x1,y1);

glTexCoord2f(1,1);glVertex2f(x2,y2);

glTexCoord2f(1,0);glVertex2f(x3,y3);

glEnd();

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?

glBegin(GL_QUADS);

glTexCoord2f(0,0);glVertex2f(x0,y0);

glTexCoord2f(0,1);glVertex2f(x1,y1);

glTexCoord2f(1,1);glVertex2f(x2,y2);

glTexCoord2f(1,0);glVertex2f(x3,y3);

glEnd();

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?