View Full Version : Texture mapping to polygons

12-02-2002, 08:06 AM
How do I map textures to polygons other than right parallelograms? For example in

glVertex2i(-10, 0);
glVertex2i(10, 0);
glVertex2i(15, 10);
glVertex2i(0, 15);
glVertex2i(-15, 10);

where would I put the calls to glTexCoord2f? Assume I have loaded the texture, which is a sqaure shape.

12-02-2002, 08:38 AM
in front of the calls to glVertex I believe

12-02-2002, 08:54 AM
Would that distort the texture? The texture is a square, and wouldn't calling glTexCoord five times distort the texture?

12-02-2002, 09:33 AM
It depends on what you pass to glTexCoord2f. 0.0, 0.0 being the lower left, and 1.0, 1.0 being the upper right. And anything between 0 and 1 being somewhere in between.

So in answer to your question, it will distort the image if all you use are 0s or 1s, but if you calculate the appropriate tex coords, you can do it w/o distorting the texture.

12-02-2002, 09:40 AM
Ohhhhh. Thank you--but wait, would the rest of the texture still be displayed even if I don't include it in glTexCoord?

12-02-2002, 11:51 AM
I belive it clips off what you dont use. I always liekd the saying "think of the coordinates as the cookie cutter and think of the texture as the dough."

12-03-2002, 12:06 PM
Ok, I figured everything out. Thank you all for helping.