Sorry for a really noob-level question…
I want to apply a specific piece of the texture (not the entire texture) to a quad. The texture is a 256×64 image and I’d like to be able to specify the relevant piece by stating the pixel coordinates of its upper-left and bottom-right corners ( [0,0] being the upper left corner of the whole image and [256,64] being the bottom right).
Any ideas on how to do that?
Thanks.
The fractional answer is correct, but if you want to use integer texture coordinates (for example in a VBO) you can use the
GL_TEXTUREmatrix to change your texture coordinate system:After that your texture coordinate units would be pixels. Another scaling strategy would be to scale so each tile is 1×1 in the final units.