Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your problem stems from a common misconception how OpenGL treats texture coordinates. </p> <p><em>The texture coordinates 0 and 1 are not on pixel centers!</em></p> <p>Textures are actually multidimensional samplers and the texture data provides the support for the sampler interpolation. Now the way this sampling works puts some constraints on the texture coordinate mapping. One boundary condition is, that support points should be equidistant along dimensions. Now remember that OpenGL supports texture wrapping.</p> <p>Your image is basically a raster, a grid of quadrats, called pixels. Say you got 8 pixels in a row</p> <pre><code> |0|1|2|3|4|5|6|7| </code></pre> <p>The texture coordinates are</p> <pre><code> |0|1|2|3|4|5|6|7| ^ ^ 0.0 1.0 </code></pre> <p>This is the well known fence post problem. Your pixel centers are actually at texture coordinates</p> <pre><code>(0/8 + 1/8)/2, (1/8 + 2/8)/2, …, (7/8 + 8/8)/2 </code></pre> <p>or more general at</p> <pre><code>(2i + 1)/2N </code></pre> <p>However in the case of text rendering you seldomly want to filter your textures; if you minify rasterized glyphs the result will look to weak, magnifying rasterized glyphs loose crispnes or get aliased.</p> <p>Texture rectangles are perfectly suited for this case, if you want to use the fixed function pipeline. In later OpenGL versions that mandate the use of shaders (3 and upwards) there is a special texture sampling function that accepts absolute texel indices instead of a sampler interpolation coordinate. Either of them is perfectly suited for the task.</p> <p>And should you use <em>Vector Textures</em> or <em>Distance Maps</em>, then the way you sample glyps is completely different anyway.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload