Imagine trying to draw an object which is covered by a portion of an arbitrary large 2D texture. This type of problem typically occurs when rendering terrain or attempting to pan over very large images. If the texture is arbitrarily large it will not entirely fit into texture memory unless it is dramatically reduced in size. Rather than suffer the degradation in image quality by using the smaller texture, it might be possible to only use the subregion of the texture that is currently visible. This is somewhat similar to the texture tiling problem discussed earlier, but rather than sequence through all of the tiles for each frame only the set of tiles necessary to draw the image need to be used [41].
There are two different approaches that could be used to address the problem. The first is to subdivide the texture into fixed sized tiles and selectively draw the portion of the geometry that intersects each tile as that tile is loaded. As discussed previously, this is difficult for GL_LINEAR filters since the locations where the geometry crosses tile boundaries need to be resampled properly. The problem could be addressed by clipping the geometry so that the texture coordinates are kept within the [0.0, 1.0] range and then use borders to handle the edges, or a single large texture consisting of all of the tiles could be used and the clipping step could be avoided.
This latter solution is not very practical with OpenGL 1.0 since the entire texture needs to be reloaded each time a new tile needs to be added, but it is addressed by the incremental loading capability added to OpenGL 1.1 and added to several OpenGL 1.0 implementations as an extension. This glTexSubImage() routine allows a subregion within an existing texture image to be updated. This makes it simple to load new tiles into areas that are no longer needed to draw the image. The ability to update portions of the texture doesn't completely solve the problem. Consider the case of a two dimensional image roam, illustrated in Figure 14, in which the view is moving to the right. As the view pans to the right, new texture tiles must be added to the right edge of the current portion of the texture and old tiles could be discarded from the left edge.
Tiles discarded on the right side of the image create holes where new tiles could be loaded into the texture, but there is a problem with the texture coordinates. Tiles loaded at the left end will correspond to low values of the t texture coordinate, but the geometry may be drawn with a single command or perhaps using automatic texture coordinate generation expecting to index those tiles with higher values of the t coordinate. The solution to the problem is to use the repeat texture mode and let the texture coordinates for the geometry extend past 1.0 The texture memory simply wraps back onto itself in a toroidal topology. The origin of the texture coordinates for the geometry must be adjusted as the leading and trailing edges of the tiles cycle through texture memory. The translation of the origin can be done using the texture matrix.
The algorithm works for both mipmap and non-mipmapped textures but for the former, tiles corresponding to each level of detail must be loaded together.
The ability to load subregions within a texture has other uses besides these paging applications. Without this capability textures must be loaded in their entirety and their widths and heights must be powers of two. In the case of video data, the images are typically not powers of two so a texture of the nearest larger power of two can be created and only the relevant subregion needs to be loaded. When drawing geometry, the texture coordinates are simply constrained to the fraction of the texture which is occupied with valid data. MIPmapping can not easily be used with non-power-of-two image data since the coarser levels will contain image data from the invalid region of the texture.