PDA

View Full Version : Texture mapping to polygons



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

glBegin(GL_POLYGON);
glVertex2i(-10, 0);
glVertex2i(10, 0);
glVertex2i(15, 10);
glVertex2i(0, 15);
glVertex2i(-15, 10);
glEnd();

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

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

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

Deiussum
12-02-2002, 10: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, 10: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?

KenR7A
12-02-2002, 12:51 PM
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, 01:06 PM
Ok, I figured everything out. Thank you all for helping.