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: Understanding Texture coordinates

  1. #1
    Intern Newbie
    Join Date
    Apr 2011
    Posts
    37

    Understanding Texture coordinates

    I'm trying to draw a simple quad with only one part of a texture used to see how texture mapping works. It's a 32 by 32 texture and I'm currently just trying to get the left strip of pixels shown.
    I first tried to map the texture coordinates with the left X zero and the right X 1/32 (0.03125). This did not work when zoomed in it blended with the pixels to the right and had a dark edge to the left.
    I read somewhere that openGL samples pixels from the center, so I tried again with 0 for left X and .5/32 (0.015625) for the right X . This was better, but still had a darker left border.

    Finally I got it to work by using .5/32 (0.015625) for both the left and right X coordinates.

    To come up with my solution I just messed with numbers until it worked, so I still do not know if I'm doing right. Can anyone explain how to exactly map only parts of a texture. Most tutorials say use zero for left and one for right, but this does not work.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,718

    Re: Understanding Texture coordinates

    It sounds like you forgot to turn off texture filtering. If you have GL_TEXTURE_MAG/MIN_FILTER set to GL_LINEAR, then you will get blending between texels. Set it to GL_NEAREST if you only want the value closest to the texel.

  3. #3
    Intern Newbie
    Join Date
    Apr 2011
    Posts
    37

    Re: Understanding Texture coordinates

    You are right! I had actually tried testing this but I was setting the wrong texture. It works now. Thanks!

Posting Permissions

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