问题描述:

This question already has an answer here:

  • OpenGL Texture Coordinates in Pixel Space

    3 answers

网友答案:

If your question is simply posed out of curiosity: AFAIK there is no standard answer to that question, since your texture coordinates don't necessesary have to end at 1.0. Also the grafic cards will process the values in a different manner (some graphic cards today support 64bit FP-Ops, for example). I think you should always try to code on the safe side, and maybe use 0.999 instead of 1.0, if applicable.

Otherwise, if you are looking for a way to read back pixels from a rendered texture, you can define your viewport as described on the website of dominik göddeke on gpgpu. If you set the viewport to the size of the texture you can simply grab back the pixels at their original coordinates. I really recommend the site, it helped me a lot.

UPDATE: The texture coordinates are interpolated between the first and the last pixel in the texture when using GL_REPEAT. So the center of the first pixel in a 4 texel texture is at 0.125, because each pixel has the width of 0.25 or 1/4.

This explains it more visually:

As you can see, the texel at [0,0] is the linear mix of [0.125,0] and [0.875,0] and equal to [1,1] in this example.

All that is very well explained on the DelphiGL Wiki (english translation)

I'm sorry for the confusion at first.

相关阅读:
Top