
- •Introduction
- •Formatting of Optional Features
- •What is the OpenGL Graphics System?
- •Our View
- •Companion Documents
- •OpenGL Operation
- •OpenGL Fundamentals
- •Floating-Point Computation
- •GL State
- •GL Command Syntax
- •Basic GL Operation
- •GL Errors
- •Begin/End Paradigm
- •Begin and End
- •Polygon Edges
- •GL Commands within Begin/End
- •Vertex Specification
- •Vertex Arrays
- •Buffer Objects
- •Vertex Arrays in Buffer Objects
- •Array Indices in Buffer Objects
- •Rectangles
- •Coordinate Transformations
- •Controlling the Viewport
- •Matrices
- •Normal Transformation
- •Generating Texture Coordinates
- •Clipping
- •Current Raster Position
- •Colors and Coloring
- •Lighting
- •ColorMaterial
- •Lighting State
- •Color Index Lighting
- •Clamping or Masking
- •Flatshading
- •Color and Associated Data Clipping
- •Final Color Processing
- •Vertex Shaders
- •Shader Objects
- •Program Objects
- •Shader Variables
- •Shader Execution
- •Required State
- •Rasterization
- •Invariance
- •Antialiasing
- •Multisampling
- •Points
- •Basic Point Rasterization
- •Point Rasterization State
- •Point Multisample Rasterization
- •Line Segments
- •Basic Line Segment Rasterization
- •Other Line Segment Features
- •Line Rasterization State
- •Line Multisample Rasterization
- •Polygons
- •Basic Polygon Rasterization
- •Stippling
- •Antialiasing
- •Options Controlling Polygon Rasterization
- •Depth Offset
- •Polygon Multisample Rasterization
- •Polygon Rasterization State
- •Pixel Rectangles
- •Pixel Storage Modes
- •The Imaging Subset
- •Pixel Transfer Modes
- •Rasterization of Pixel Rectangles
- •Pixel Transfer Operations
- •Pixel Rectangle Multisample Rasterization
- •Bitmaps
- •Texturing
- •Compressed Texture Images
- •Texture Parameters
- •Depth Component Textures
- •Cube Map Texture Selection
- •Texture Wrap Modes
- •Texture Completeness
- •Texture State and Proxy State
- •Texture Objects
- •Texture Environments and Texture Functions
- •Texture Comparison Modes
- •Texture Application
- •Color Sum
- •Fragment Shaders
- •Shader Variables
- •Shader Execution
- •Antialiasing Application
- •Multisample Point Fade
- •Per-Fragment Operations
- •Pixel Ownership Test
- •Scissor Test
- •Multisample Fragment Operations
- •Alpha Test
- •Stencil Test
- •Depth Buffer Test
- •Occlusion Queries
- •Blending
- •Dithering
- •Logical Operation
- •Additional Multisample Fragment Operations
- •Whole Framebuffer Operations
- •Selecting a Buffer for Writing
- •Fine Control of Buffer Updates
- •Clearing the Buffers
- •The Accumulation Buffer
- •Drawing, Reading, and Copying Pixels
- •Writing to the Stencil Buffer
- •Reading Pixels
- •Copying Pixels
- •Pixel Draw/Read State
- •Special Functions
- •Evaluators
- •Selection
- •Feedback
- •Display Lists
- •Flush and Finish
- •Hints
- •State and State Requests
- •Querying GL State
- •Simple Queries
- •Data Conversions
- •Enumerated Queries
- •Texture Queries
- •Stipple Query
- •Color Matrix Query
- •Color Table Query
- •Convolution Query
- •Histogram Query
- •Minmax Query
- •Pointer and String Queries
- •Occlusion Queries
- •Buffer Object Queries
- •Shader and Program Queries
- •Saving and Restoring State
- •State Tables
- •Invariance
- •Corollaries
- •Version 1.1
- •Version 1.2
- •Imaging Subset
- •Version 1.2.1
- •Version 1.3
- •Version 1.4
- •Fog Coordinate
- •Texture LOD Bias
- •Version 1.5
- •Version 2.0
- •ARB Extensions
- •Texture Mirrored Repeat
- •OpenGL Shading Language

3.8. TEXTURING |
163 |
Counting from zero, the nth pixel group is assigned to the texel with internal integer coordinates [i], where
i = x + (n mod w)
Texture images with compressed internal formats may be stored in such a way that it is not possible to modify an image with subimage commands without having to decompress and recompress the texture image. Even if the image were modified in this manner, it may not be possible to preserve the contents of some of the texels outside the region being modified. To avoid these complications, the GL does not support arbitrary modifications to texture images with compressed internal formats. Calling TexSubImage3D, CopyTexSubImage3D, TexSubImage2D, CopyTexSubImage2D, TexSubImage1D, or CopyTexSubImage1D will result in an INVALID OPERATION error if xoffset, yoffset, or zoffset is not equal to −bs (border width). In addition, the contents of any texel outside the region modified by such a call are undefined. These restrictions may be relaxed for specific compressed internal formats whose images are easily modified.
3.8.3 Compressed Texture Images
Texture images may also be specified or modified using image data already stored in a known compressed image format. The GL currently defines no such formats, but provides mechanisms for GL extensions that do.
The commands
void CompressedTexImage1D( enum target, int level, enum internalformat, sizei width, int border, sizei imageSize, void *data );
void CompressedTexImage2D( enum target, int level, enum internalformat, sizei width, sizei height, int border, sizei imageSize, void *data );
void CompressedTexImage3D( enum target, int level, enum internalformat, sizei width, sizei height,
sizei depth, int border, sizei imageSize, void *data );
define one-, two-, and three-dimensional texture images, respectively, with incoming data stored in a specific compressed image format. The target, level, internalformat, width, height, depth, and border parameters have the same meaning as in
TexImage1D, TexImage2D, and TexImage3D. data points to compressed image data stored in the compressed image format corresponding to internalformat. Since
Version 2.0 - October 22, 2004

3.8. TEXTURING |
164 |
the GL provides no specific image formats, using any of the six generic compressed internal formats as internalformat will result in an INVALID ENUM error.
For all other compressed internal formats, the compressed image will be decoded according to the specification defining the internalformat token. Compressed texture images are treated as an array of imageSize ubytes beginning at address data. All pixel storage and pixel transfer modes are ignored when decoding a compressed texture image. If the imageSize parameter is not consistent with the format, dimensions, and contents of the compressed image, an INVALID VALUE error results. If the compressed image is not encoded according to the defined image format, the results of the call are undefined.
Specific compressed internal formats may impose format-specific restrictions on the use of the compressed image specification calls or parameters. For example, the compressed image format might be supported only for 2D textures, or might not allow non-zero border values. Any such restrictions will be documented in the extension specification defining the compressed internal format; violating these restrictions will result in an INVALID OPERATION error.
Any restrictions imposed by specific compressed internal formats will be invariant, meaning that if the GL accepts and stores a texture image in compressed form, providing the same image to CompressedTexImage1D,
CompressedTexImage2D, or CompressedTexImage3D will not result in an
INVALID OPERATION error if the following restrictions are satisfied:
•data points to a compressed texture image returned by GetCompressedTexImage (section 6.1.4).
•target, level, and internalformat match the target, level and format parameters provided to the GetCompressedTexImage call returning data.
• width, |
height, |
depth, |
border, internalformat, and image- |
Size |
match the |
values |
of TEXTURE WIDTH, TEXTURE HEIGHT, |
TEXTURE DEPTH, |
TEXTURE BORDER, TEXTURE INTERNAL FORMAT, |
and TEXTURE COMPRESSED IMAGE SIZE for image level level in effect at the time of the GetCompressedTexImage call returning data.
This guarantee applies not just to images returned by GetCompressedTexImage, but also to any other properly encoded compressed texture image of the same size and format.
The commands
void CompressedTexSubImage1D( enum target, int level, int xoffset, sizei width, enum format, sizei imageSize, void *data );
Version 2.0 - October 22, 2004

3.8. TEXTURING |
165 |
void CompressedTexSubImage2D( enum target, int level, int xoffset, int yoffset, sizei width, sizei height, enum format, sizei imageSize, void *data );
void CompressedTexSubImage3D( enum target, int level, int xoffset, int yoffset, int zoffset, sizei width, sizei height, sizei depth, enum format,
sizei imageSize, void *data );
respecify only a rectangular region of an existing texture array, with incoming data stored in a known compressed image format. The target, level, xoffset, yoffset, zoffset, width, height, and depth parameters have the same meaning as in TexSubImage1D, TexSubImage2D, and TexSubImage3D. data points to compressed image data stored in the compressed image format corresponding to format. Since the core GL provides no specific image formats, using any of these six generic compressed internal formats as format will result in an INVALID ENUM error.
The image pointed to by data and the imageSize parameter are interpreted as though they were provided to CompressedTexImage1D, CompressedTexImage2D, and CompressedTexImage3D. These commands do not provide for image format conversion, so an INVALID OPERATION error results if format does not match the internal format of the texture image being modified. If the imageSize parameter is not consistent with the format, dimensions, and contents of the compressed image (too little or too much data), an INVALID VALUE error results.
As with CompressedTexImage calls, compressed internal formats may have additional restrictions on the use of the compressed image specification calls or parameters. Any such restrictions will be documented in the specification defining the compressed internal format; violating these restrictions will result in an
INVALID OPERATION error.
Any restrictions imposed by specific compressed internal formats will be invariant, meaning that if the GL accepts and stores a texture image in compressed form, providing the same image to CompressedTexSubImage1D, CompressedTexSubImage2D, CompressedTexSubImage3D will not result in an
INVALID OPERATION error if the following restrictions are satisfied:
•data points to a compressed texture image returned by GetCompressedTexImage (section 6.1.4).
•target, level, and format match the target, level and format parameters provided to the GetCompressedTexImage call returning data.
• width, |
height, depth, format, and imageSize |
match the val- |
ues |
of TEXTURE WIDTH, TEXTURE HEIGHT, |
TEXTURE DEPTH, |
Version 2.0 - October 22, 2004

3.8. TEXTURING |
166 |
TEXTURE INTERNAL FORMAT, and TEXTURE COMPRESSED IMAGE SIZE for image level level in effect at the time of the GetCompressedTexImage call returning data.
•width, height, depth, format match the values of TEXTURE WIDTH,
TEXTURE HEIGHT, TEXTURE DEPTH, and TEXTURE INTERNAL FORMAT currently in effect for image level level.
• xoffset, yoffset, and zoffset are all −b, where b is the value of TEXTURE BORDER currently in effect for image level level.
This guarantee applies not just to images returned by GetCompressedTexImage, but also to any other properly encoded compressed texture image of the same size.
Calling CompressedTexSubImage3D, CompressedTexSubImage2D, or CompressedTexSubImage1D will result in an INVALID OPERATION error if xoffset, yoffset, or zoffset is not equal to −bs (border width), or if width, height, and depth do not match the values of TEXTURE WIDTH, TEXTURE HEIGHT, or TEXTURE DEPTH, respectively. The contents of any texel outside the region modified by the call are undefined. These restrictions may be relaxed for specific compressed internal formats whose images are easily modified.
3.8.4 Texture Parameters
Various parameters control how the texture array is treated when specified or changed, and when applied to a fragment. Each parameter is set by calling
void TexParameter{if}( enum target, enum pname, T param ); void TexParameter{if}v( enum target, enum pname,
T params );
target is the target, either TEXTURE 1D, TEXTURE 2D, TEXTURE 3D, or
TEXTURE CUBE MAP. pname is a symbolic constant indicating the parameter to be set; the possible constants and corresponding parameters are summarized in table 3.19. In the first form of the command, param is a value to which to set a single-valued parameter; in the second form of the command, params is an array of parameters whose type depends on the parameter being set. If the values for
TEXTURE BORDER COLOR, or the value for TEXTURE PRIORITY are specified as integers, the conversion for signed integers from table 2.9 is applied to convert these values to floating-point, followed by clamping each value to lie in [0, 1].
In the remainder of section 3.8, |
denote by lodmin, lodmax, levelbase, |
and levelmax the values of the |
texture parameters TEXTURE MIN LOD, |
Version 2.0 - October 22, 2004

3.8. TEXTURING |
167 |
Name |
Type |
Legal Values |
|
|
|
TEXTURE WRAP S |
integer |
CLAMP, CLAMP TO EDGE, REPEAT, |
|
|
CLAMP TO BORDER, |
|
|
MIRRORED REPEAT |
|
|
|
TEXTURE WRAP T |
integer |
CLAMP, CLAMP TO EDGE, REPEAT, |
|
|
CLAMP TO BORDER, |
|
|
MIRRORED REPEAT |
|
|
|
TEXTURE WRAP R |
integer |
CLAMP, CLAMP TO EDGE, REPEAT, |
|
|
CLAMP TO BORDER, |
|
|
MIRRORED REPEAT |
|
|
|
TEXTURE MIN FILTER |
integer |
NEAREST, |
|
|
LINEAR, |
|
|
NEAREST MIPMAP NEAREST, |
|
|
NEAREST MIPMAP LINEAR, |
|
|
LINEAR MIPMAP NEAREST, |
|
|
LINEAR MIPMAP LINEAR, |
|
|
|
TEXTURE MAG FILTER |
integer |
NEAREST, |
|
|
LINEAR |
|
|
|
TEXTURE BORDER COLOR |
4 floats |
any 4 values in [0, 1] |
TEXTURE PRIORITY |
float |
any value in [0, 1] |
TEXTURE MIN LOD |
float |
any value |
|
|
|
TEXTURE MAX LOD |
float |
any value |
|
|
|
TEXTURE BASE LEVEL |
integer |
any non-negative integer |
|
|
|
TEXTURE MAX LEVEL |
integer |
any non-negative integer |
|
|
|
TEXTURE LOD BIAS |
float |
any value |
|
|
|
DEPTH TEXTURE MODE |
enum |
LUMINANCE, INTENSITY, ALPHA |
|
|
|
TEXTURE COMPARE MODE |
enum |
NONE, COMPARE R TO TEXTURE |
|
|
|
TEXTURE COMPARE FUNC |
enum |
LEQUAL, GEQUAL |
|
|
LESS, GREATER, |
|
|
EQUAL, NOTEQUAL, |
|
|
ALWAYS, NEVER |
|
|
|
GENERATE MIPMAP |
boolean |
TRUE or FALSE |
|
|
|
Table 3.19: Texture parameters and their values.
Version 2.0 - October 22, 2004