The texture border is most useful when attempting to use a single high resolution texture image which is too large for the OpenGL implementation to support as a single texture map. For this case, the texture can be broken up into multiple tiles, each with a 1 pixel wide border from the neighboring tiles. The texture tiles can then be loaded and used for rendering in several passes. For example, if a 1K by 1K texture is broken up into four 512 by 512 images, the four images would correspond to the texture coordinate ranges (0-0.5,0-0.5), (0.5,1.0,0-0.5), (0-0.5,0.5,1.0) and (.5-1.0,.5-1.0). As each tile is loaded, only the portions of the geometry that correspond to the appropriate texture coordinate ranges for a given tile should be drawn. If you had a single triangle whose texture coordinates were (.1,.1), (.1,.7), and (.8,.8), you would clip the triangle against the four tile regions and draw only the portion of the triangle that intersects with that region as shown in Figure 30. At the same time, the original texture coordinates need to be adjusted to correspond to the scaled and translated texture space represented by the tile. This transformation can be easily performed by loading the appropriate scale and translation onto the texture matrix stack.
Unfortunately, OpenGL does not provide much assistance for performing the clipping operation. If the input primitives are quads and they are appropriately aligned in object space with the texture, then the clipping operation is trivial; otherwise, it may involve substantially more work. One method to assist with the clipping uses stenciling to control which textured fragments are kept. Stencil testing is described in Section 8.6. Then you are left with the problem of setting the stencil bits appropriately. The easiest way to do this is to produce alpha values that are proportional to the texture coordinate values and use glAlphaFunc() to reject alpha values that you do not wish to keep. Unfortunately, you can not easily map a multidimensional texture coordinate value (e.g., s,t) to an alpha value by simply interpolating the original vertex alpha values, so it is best to use a multidimensional texture itself which has some portion of the texture with zero alpha and some portion with it equal to one. The texture coordinates are then scaled so that the textured polygon map to texels with an alpha of 1.0 for pixels to be retained and 0.0 for pixels to be rejected.
OpenGL 1.2 adds an alternative clamping behavior when the texture wrap mode is set to GL_CLAMP_TO_EDGE.7 This mode clamps the texture coordinates such that the texture border is never sampled. The filtered color is derived only from texels at the edge of the texture image. Unlike OpenGL's standard texture clamping, the clamp to edge behavior is unable to guarantee a consistent border appearance when used with mipmapping because the clamping range changes with each mipmap level because the clamping range depends on the selected mipmap level's dimensions. The clamp to edge behavior is easier to implement in hardware than OpenGL's standard clamping with texture borders because the texture dimensions are not augmented by additional border texels the dimensions are efficient powers of two. The clamp to edge behavior matches the texture clamping behavior of Direct3D.