Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: How to fit a only a part of a texture?

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    8

    How to fit a only a part of a texture?

    This may sound stupid, but If I have a texture 128x128px and a quad 120x120x can I texture it at 1:1 ratio (without clamping/resizing the texture to fit the quad)? Or maybe better - how do I "cut off" a part of the texture to fit the quad?

    E.g.
    Code :
    |-----------| 
    |   _____   |
    |  |     |  |
    |  |Quad |  |
    |  |_____|  |
    |________Tex|

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2010
    Posts
    493

    Re: How to fit a only a part of a texture?

    The mapping between texture and geometry is determined by the texture coordinates you assign to each vertex of the geometry. To get the one-to-one mapping, you give the lower left vertex in your image tex coords (0, 0) and the upper right one (1, 1) and the remaining vertices accordingly.

    To map the center area of the texture you'd use something like (0.25, 0.25) for the lower left and (0.75, 0.75) for the upper right vertex.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2011
    Posts
    8

    Re: How to fit a only a part of a texture?

    Thanks, I'll try it out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •