Applying a texture to a primitive implies a mapping from texture image
space to framebuffer image space.
In general,
this mapping involves a reconstruction of the sampled texture image,
followed by a homogeneous warping implied by the mapping to framebuffer
space,
then a filtering,
followed finally by a resampling of the filtered, warped,
reconstructed image before applying it to a fragment.
In the GL this mapping is approximated by one of two simple filtering schemes.
One of these schemes is selected based on whether the mapping from texture
space to framebuffer space is deemed to * magnify* or * minify*
the texture image.
The choice is governed by a scale factor and
;
if is less than or equal to some constant
(the selection of the constant is described below in section 3.8.2)
the texture is said to be magnified;
if it is greater,
the texture is minified. is called the * level of detail*.

Let be the function that associates an **s** texture coordinate
with each set of window coordinates that lie within a primitive;
define analogously.
Let and
(for a one-dimensional texture, define ).
For a polygon,
is given at a fragment with window coordinates
by

where indicates the derivative of
**u** with respect to window **x**,
and similarly for the other derivatives.
For a line,
the formula is

where and with and being the segment's window coordinate endpoints and . For a point, pixel rectangle, or bitmap, .

While it is generally agreed that equations 3.11 and 3.12 give the best results when texturing, they are often impractical to implement. Therefore, an implementation may approximate the ideal with a function subject to these conditions:

- is continuous and monotonically increasing in each of , , , and ,
- Let
Then .

When indicates minification,
the value assigned to ` TEXTURE_MIN_FILTER` is used
to determine how the texture value for a fragment is selected.
When ` TEXTURE_MIN_FILTER` is ` NEAREST`,
the texel nearest (in Manhattan distance) to that specified by
is obtained.
This means the texel at location becomes the texture value,
with **i** given by

(Recall that if ` TEXTURE_WRAP_S` is ` REPEAT`,
then .)
Similarly, **j** is found as

For a one-dimensional texture, **j** is irrelevant;
the texel at location **i** becomes the texture value.

When ` TEXTURE_MIN_FILTER` is ` LINEAR`,
a square of texels is selected.
This square is obtained by first computing

and

Then

and

Let

where denotes the fractional part of **x**.
Let be the texel at location in the texture image.
Then the texture value, is found as

for a two-dimensional texture. For a one-dimensional texture,

where indicates the texel at location **i** in the one-dimensional
texture.
If any of the selected (or ) in the above equations
refer to a border texel with
,
,
,
or ,
then the border color given by the current setting of
` TEXTURE_BORDER_COLOR` is used instead of the unspecified value or values.
The RGBA values of the ` TEXTURE_BORDER_COLOR` are interpreted to match the texture's
internal format in a manner consistent with Table 3.7.

Sat Mar 29 02:23:21 PST 1997