OpenGL provides a general means for generating texture-mapped primitives (Figure 4). When texturing is enabled, each fragment's texture coordinates index a texture image, generating a texel. This texel may have between one and four components, so that a texture image may represent, for example, intensity only (one component), RGB color (three components), or RGBA color (four components). Once the texel is obtained, it modifies the fragment's color according to a specifiable texture environment.
A texture image is specified using glTexImage, which takes arguments similar to those of glDrawpixels, so that the same image format may be used whether that image is destined for the framebuffer or texture memory. In addition, glTexImage may be used to specify mipmaps[3] so that a texture may be filtered as it is applied to a primitive. The filter function (and whether or not it implies mipmaps) is controlled by a number of specifiable parameters using glTexParameter. The texture environment is selected with glTexEnv.
Finally, after texturing, a fog function (if enabled) is applied to each fragment. The fog function blends the incoming color with a constant (specifiable) fog color according to a computed weighting factor. This factor is a function of the distance (or an approximation to the distance) from the viewer to the 3D point that corresponds to the fragment. Exponential fog simulates atmospheric fog and haze, while linear fog may be used to produce depth-cueing.