Скачиваний:
47
Добавлен:
17.03.2015
Размер:
2.46 Mб
Скачать

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

Соседние файлы в папке OpenGL