Results 1 to 7 of 7

Thread: Texture mapping to polygons

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2005
    Posts
    3

    Texture mapping to polygons

    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.

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2002
    Posts
    189

    Re: Texture mapping to polygons

    in front of the calls to glVertex I believe

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2005
    Posts
    3

    Re: Texture mapping to polygons

    Would that distort the texture? The texture is a square, and wouldn't calling glTexCoord five times distort the texture?

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: Texture mapping to polygons

    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.
    Deiussum
    Software Engineer and OpenGL enthusiast

  5. #5
    Guest

    Re: Texture mapping to polygons

    Ohhhhh. Thank you--but wait, would the rest of the texture still be displayed even if I don't include it in glTexCoord?

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2002
    Posts
    20

    Re: Texture mapping to polygons

    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."

  7. #7
    Guest

    Re: Texture mapping to polygons

    Ok, I figured everything out. Thank you all for helping.

Similar Threads

  1. Mapping two polygons
    By jenny_wui in forum OpenGL: General
    Replies: 0
    Last Post: 01-21-2013, 10:17 PM
  2. Drawing Polygons and Texture Mapping
    By mhaseeb in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-12-2009, 10:03 AM
  3. To display of concave polygons, polygons containing holes
    By deepa in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-13-2004, 09:22 PM
  4. Spreading a texture over multiple polygons
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-29-2002, 04:52 AM
  5. missing polygons with 3d texture data
    By krol in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 03-19-2002, 07:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean