sub-textures (mosaics), borders, and filtering...


I want to create a single texture of many smaller images which can be applied to quads individually. This is very similar to a font set texture, as described in Mark Kilgard’s texfont, however I want to be able to address any arbitrary sub rectangle of the texture, not a specific area for each glyph.

As mentioned in the texfont doc, there are problems with adjancent areas (glyphs) pixels creeping in when filtering is enabled. I’m not concerned with mipmaps because my application is 2d, but it is still visible with plain linear filtering.

You can use TEXTURE_WRAP* border clamping to fix this adjacent pixel problem for an entire texture, but I don’t see any way to do it when using glTexCoord* to specify a sub-texture. Because I want to address an arbitrary rectangle, adding empty pixels in the texture is not an option, as it could be with font glyphs.

Is there any way to fix the border clamping when using texture coords between 1.0 and 0?


You could ofcourse skip filtering all together… GL_NEAREST or something…