Program for computing texture coordinates.

Hi,

I have to fetch data from my texture images using texture coordinates. Does anyone here know how to fetch data from texture images using texture coordinates. Here is what I really intend to do:

I create a NPOT floating-point texture like TexA:
TexA:
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15

So, this TexA is 4x4. I am aware that in OpenGL texture coordinates are central pixel values, I mean like (0.5, 0.5)…(3.5, 3.5). So, I want to write a program which computes these texture coordinates values and when passed to the texture image behaves like:
(0.5, 0.5) fetches 0.
(0.5, 1.5) fetches 1.
(0.5, 2.5) fetches 2.

(3,5, 2.5) fetches 14.
(3.5, 3.5) fetches 15.

Please help me to create this program. I would appreciate if someone could pass their code if they have already done so.

Thanks.

0, 0 fetches the lower left, 1,1 fetches the upper right corner and not at the center of the texel it may be filtered half way between the edge and border or two opposite edges depending on the wrap mode and filters.

You can use the texture matrix to adjust this behavior by scaling etc.

Moving this to beginners, it’s not an advanced topic.