glTextureView.3G - Man Page

initialize a texture as a data alias of another texture's data store

C Specification

void glTextureView(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);

Parameters

texture

Specifies the texture object to be initialized as a view.

target

Specifies the target to be used for the newly initialized texture.

origtexture

Specifies the name of a texture object of which to make a view.

internalformat

Specifies the internal format for the newly created view.

minlevel

Specifies lowest level of detail of the view.

numlevels

Specifies the number of levels of detail to include in the view.

minlayer

Specifies the index of the first layer to include in the view.

numlayers

Specifies the number of layers to include in the view.

Description

glTextureView initializes a texture object as an alias, or view of another texture object, sharing some or all of the parent texture's data store with the initialized texture. texture specifies a name previously reserved by a successful call to glGenTextures() but that has not yet been bound or given a target. target specifies the target for the newly initialized texture and must be compatible with the target of the parent texture, given in origtexture as specified in the following table:

Original TargetCompatible New Targets
GL_TEXTURE_1DGL_TEXTURE_1D, GL_TEXTURE_1D_ARRAY
GL_TEXTURE_2DGL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY
GL_TEXTURE_3DGL_TEXTURE_3D
GL_TEXTURE_CUBE_MAPGL_TEXTURE_CUBE_MAP, GL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY
GL_TEXTURE_RECTANGLEGL_TEXTURE_RECTANGLE
GL_TEXTURE_BUFFERnone
GL_TEXTURE_1D_ARRAYGL_TEXTURE_1D, GL_TEXTURE_1D_ARRAY
GL_TEXTURE_2D_ARRAYGL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY
GL_TEXTURE_CUBE_MAP_ARRAYGL_TEXTURE_CUBE_MAP, GL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY
GL_TEXTURE_2D_MULTISAMPLEGL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MULTISAMPLE_ARRAY
GL_TEXTURE_2D_MULTISAMPLE_ARRAYGL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MULTISAMPLE_ARRAY

The value of GL_TEXTURE_IMMUTABLE_FORMAT for origtexture must be GL_TRUE. After initialization, texture inherits the data store of the parent texture, origtexture and is usable as a normal texture object with target target. Data in the shared store is reinterpreted with the new internal format specified by internalformat. internalformat must be compatible with the internal format of the parent texture as specified in the following table:

ClassInternal Formats
128-bitGL_RGBA32F, GL_RGBA32UI, GL_RGBA32I
96-bitGL_RGB32F, GL_RGB32UI, GL_RGB32I
64-bitGL_RGBA16F, GL_RG32F, GL_RGBA16UI,
                       GL_RG32UI, GL_RGBA16I, GL_RG32I, GL_RGBA16, GL_RGBA16_SNORM
48-bitGL_RGB16, GL_RGB16_SNORM, GL_RGB16F, GL_RGB16UI, GL_RGB16I
32-bitGL_RG16F, GL_R11F_G11F_B10F, GL_R32F, GL_RGB10_A2UI,
                                           GL_RGBA8UI, GL_RG16UI, GL_R32UI, GL_RGBA8I,
                                           GL_RG16I, GL_R32I, GL_RGB10_A2, GL_RGBA8,
                                           GL_RG16, GL_RGBA8_SNORM, GL_RG16_SNORM, GL_SRGB8_ALPHA8,
                                           GL_RGB9_E5
24-bitGL_RGB8, GL_RGB8_SNORM, GL_SRGB8,
                                           GL_RGB8UI, GL_RGB8I
16-bitGL_R16F, GL_RG8UI, GL_R16UI, GL_RG8I,
                                           GL_R16I, GL_RG8, GL_R16, GL_RG8_SNORM, GL_R16_SNORM
8-bitGL_R8UI, GL_R8I, GL_R8, GL_R8_SNORM
GL_RGTC1_REDGL_COMPRESSED_RED_RGTC1, GL_COMPRESSED_SIGNED_RED_RGTC1
GL_RGTC2_RGGL_COMPRESSED_RG_RGTC2, GL_COMPRESSED_SIGNED_RG_RGTC2
GL_BPTC_UNORMGL_COMPRESSED_RGBA_BPTC_UNORM, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM
GL_BPTC_FLOATGL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT

If the original texture is an array or has multiple mipmap levels, the parameters minlayer, numlayers, minlevel, and numlevels control which of those slices and levels are considered part of the texture. The minlevel and minlayer parameters are relative to the view of the original texture. If numlayers or numlevels extend beyond the original texture, they are clamped to the max extent of the original texture.

If the new texture's target is GL_TEXTURE_CUBE_MAP, the clamped numlayers must be equal to 6. If the new texture's target is GL_TEXTURE_CUBE_MAP_ARRAY, then numlayers counts layer-faces rather than layers, and the clamped numlayers must be a multiple of 6. If the new texture's target is GL_TEXTURE_CUBE_MAP or GL_TEXTURE_CUBE_MAP_ARRAY, the width and height of the original texture's levels must be equal.

When the original texture's target is GL_TEXTURE_CUBE_MAP, the layer parameters are interpreted in the same order as if it were a GL_TEXTURE_CUBE_MAP_ARRAY with 6 layer-faces.

If target is GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_RECTANGLE, or GL_TEXTURE_2D_MULTISAMPLE, numlayers must equal 1.

The dimensions of the original texture must be less than or equal to the maximum supported dimensions of the new target. For example, if the original texture has a GL_TEXTURE_2D_ARRAY target and its width is greater than GL_MAX_CUBE_MAP_TEXTURE_SIZE, an error will be generated if glTextureView is called to create a GL_TEXTURE_CUBE_MAP view.

Texture commands that take a level or layer parameter, such as glTexSubImage2D(), interpret that parameter to be relative to the view of the texture. i.e. the mipmap level of the data store that would be updated via glTexSubImage2D() would be the sum of level and the value of GL_TEXTURE_VIEW_MIN_LEVEL.

Errors

GL_INVALID_VALUE is generated if minlayer or minlevel are larger than the greatest layer or level of origtexture.

GL_INVALID_OPERATION is generated if target is not compatible with the target of origtexture.

GL_INVALID_OPERATION is generated if the dimensions of origtexture are greater than the maximum supported dimensions for target.

GL_INVALID_OPERATION is generated if internalformat is not compatible with the internal format of origtexture.

GL_INVALID_OPERATION is generated if texture has already been bound or otherwise given a target.

GL_INVALID_OPERATION is generated if the value of GL_TEXTURE_IMMUTABLE_FORMAT for origtexture is not GL_TRUE.

GL_INVALID_OPERATION is generated if origtexture is not the name of an existing texture object.

GL_INVALID_VALUE is generaged if target is GL_TEXTURE_CUBE_MAP and numlayers is not 6, or if target is GL_TEXTURE_CUBE_MAP_ARRAY and numlayers is not an integer multiple of 6.

GL_INVALID_VALUE is generated if target is GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_RECTANGLE, or GL_TEXTURE_2D_MULTISAMPLE and numlayers does not equal 1.

GL_INVALID_VALUE is generated if texture zero or is not the name of a texture previously returned from a successful call to glGenTextures().

Associated Gets

glTexParameter() with arguments GL_TEXTURE_VIEW_MIN_LEVEL, GL_TEXTURE_VIEW_NUM_LEVELS, GL_TEXTURE_VIEW_MIN_LAYER, GL_TEXTURE_VIEW_NUM_LAYERS, or GL_TEXTURE_IMMUTABLE_LEVELS.

Version Support

OpenGL Version
Function / Feature Name2.02.13.03.13.23.34.04.14.24.34.44.5
glTextureView---------

See Also

glTexStorage1D(), glTexStorage2D(), glTexStorage3D(), glGetTexParameter().

Referenced By

glGetTexParameter.3G(3).

07/18/2024