1.10. 纹理 Texturing
The area of texture mapping is one of the more complex areas of the OpenGL API. It has been
extended more often than most of the other areas of OpenGL primarily because this was the
area of graphics for which hardware was the least mature when OpenGL was defined in the
early 1990s. The programmability added through the OpenGL Shading Language in OpenGL 2.0
makes this area much more straightforward, but the existing OpenGL APIs are still used to
create, modify, and define the behavior of textures. This section describes the texturing
functionality as it existed for OpenGL 1.5. Some significant changes have been made to this
model by OpenGL 2.0, particularly to the concept of texture units, and are described later in
this book.
OpenGL currently supports four basic types of texture maps: onedimensional, two-dimensional,
three-dimensional, and cube maps. (Only one- and two-dimensional textures were supported in
OpenGL 1.0.) A 1D TEXTURE
is an array containing width pixel values, a 2D TEXTURE
is an array
containing width x height pixel values, and a 3D
TEXTURE is an array containing width x height x
depth pixel values. A CUBE MAP TEXTURE contains six two-dimensional textures: one for each major
axis direction (i.e., ±x, ±y, and ±z).
OpenGL has the notion of a TEXTURE UNIT. A texture unit corresponds to the underlying piece of
graphics hardware that performs the various texturing operations. With OpenGL 1.3, support
was added for multiple texture units. Each texture unit maintains the following state for
performing texturing operations: