GLGETCOMPRESSEDTEXTU(3G)

πŸ’… NAME

okay so bestie, this one is glGetCompressedTextureSubImage β€” it grabs you a sub-region of a compressed texture image out of a compressed texture object. not the whole thing, just the slice you asked for. iconic behavior honestly ✨

(it's from the 3G manual, the OpenGL one, in case you were wondering πŸŽ€)


🌸 C SPECIFICATION

void glGetCompressedTextureSubImage(GLuint texture, GLint level,
                                    GLint xoffset, GLint yoffset,
                                    GLint zoffset, GLsizei width,
                                    GLsizei height, GLsizei depth,
                                    GLsizei bufSize, void *pixels);

like, that's the whole signature, no cap 🫢


✨ PARAMETERS

  • texture β€” the name of the source texture object. it must be one of GL_TEXTURE_1D, GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP, GL_TEXTURE_CUBE_MAP_ARRAY or GL_TEXTURE_RECTANGLE. and in specific β€” buffer and multisample textures are not permitted, sorry bestie πŸ™ˆ
  • level β€” the level-of-detail number, aka which mipmap we're talking about. level 0 is the base image level, and level n is the *n*th mipmap reduction image. so level 0 is the main character πŸ‘‘
  • xoffset β€” the texel offset in the x direction within the texture array.
  • yoffset β€” the texel offset in the y direction within the texture array.
  • zoffset β€” the texel offset in the z direction within the texture array.
  • width β€” the width of the texture subimage. must be a multiple of the compressed block's width, unless the offset is zero and the size equals the texture image size. (that exception is doing a lot of work, lowkey πŸ’€)
  • height β€” the height of the texture subimage. must be a multiple of the compressed block's height, unless the offset is zero and the size equals the texture image size.
  • depth β€” the depth of the texture subimage. must be a multiple of the compressed block's depth, unless the offset is zero and the size equals the texture image size.
  • bufSize β€” the size of the buffer that receives the retrieved pixel data. don't skimp on this one fr fr.
  • pixels β€” returns the texture subimage. should be a pointer to an array of the type specified by type. πŸ’–

πŸ¦‹ DESCRIPTION

so glGetCompressedTextureSubImage lets you obtain a sub-region of a compressed texture image instead of the whole entire image β€” as long as the compressed data are arranged into fixed-size blocks of texels. that's the catch, that's the vibe check 🧚

texture is the name of the texture object, and it must not be a buffer or multisample texture. the effective target is the value of GL_TEXTURE_TARGET for texture. level and pixels have the same meaning as the corresponding arguments of glCompressedTexSubImage3D. and bufSize indicates the size of the buffer to receive the retrieved pixel data. slay πŸ’…

for cube map textures, the behavior is as though glGetCompressedTexImage were called once for each requested face (selected by zoffset and depth, as described below) with target corresponding to the requested texture cube map face as indicated by the table presented below. pixels is offset appropriately for each successive image. okay so here's the layer-to-face mapping, bestie, memorize it:

  • Layer number 0 β†’ GL_TEXTURE_CUBE_MAP_POSITIVE_X
  • Layer number 1 β†’ GL_TEXTURE_CUBE_MAP_NEGATIVE_X
  • Layer number 2 β†’ GL_TEXTURE_CUBE_MAP_POSITIVE_Y
  • Layer number 3 β†’ GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
  • Layer number 4 β†’ GL_TEXTURE_CUBE_MAP_POSITIVE_Z
  • Layer number 5 β†’ GL_TEXTURE_CUBE_MAP_NEGATIVE_Z

xoffset, yoffset and zoffset indicate the position of the subregion to return. width, height and depth indicate the size of the region to return. these arguments have the same meaning as for glCompressedTexSubImage3D, though there are extra restrictions β€” described in the errors section below, so like, read it πŸ™ˆ

the mapping between the xoffset, yoffset, zoffset, width, height and depth parameters and the faces, layers, and layer-faces for cube map, array, and cube map array textures is the same as for glGetTextureSubImage.

the xoffset, yoffset, zoffset offsets and width, height and depth sizes must be multiples of the values of GL_PACK_COMPRESSED_BLOCK_WIDTH, GL_PACK_COMPRESSED_BLOCK_HEIGHT, and GL_PACK_COMPRESSED_BLOCK_DEPTH respectively β€” unless offset is zero and the corresponding size is the same as the texture size in that dimension. yes, every single one. no shortcuts πŸ”₯

pixel storage modes are treated as for glGetCompressedTexSubImage. the texel at (xoffset, yoffset, zoffset) will be stored at the location indicated by pixels and the current pixel packing parameters. periodt. ⭐


πŸ’€ ERRORS

like, be careful out here. here's every way to mess this up:

  • GL_INVALID_OPERATION is generated if texture is the name of a buffer or multisample texture.
  • GL_INVALID_OPERATION is generated if the buffer size required to store the requested data is greater than bufSize.
  • GL_INVALID_OPERATION is generated if the texture compression format is not based on fixed-size blocks.
  • GL_INVALID_VALUE is generated if texture is not the name of an existing texture object.
  • GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset are negative.
  • GL_INVALID_VALUE is generated if xoffset + width is greater than the texture's width, yoffset + height is greater than the texture's height, or zoffset + depth is greater than the texture's depth.
  • GL_INVALID_VALUE is generated if the effective target is GL_TEXTURE_1D and either yoffset is not zero, or height is not one.
  • GL_INVALID_VALUE is generated if the effective target is GL_TEXTURE_1D, GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D or GL_TEXTURE_RECTANGLE and either zoffset is not zero, or depth is not one.
  • GL_INVALID_VALUE is generated if xoffset, yoffset or zoffset is not a multiple of the compressed block width, height or depth respectively.
  • GL_INVALID_VALUE is generated if width, height or depth is not a multiple of the compressed block width, height or depth respectively, unless the offset is zero and the size equals the texture image size.
not me listing ten error conditions 😭 but like, genuinely, read them. they will find you.

🌈 VERSION SUPPORT

okay so here's the moment of truth, the whole grid, bestie. function name is glGetCompressedTextureSubImage, and across every OpenGL version column:

  • 2.0 β€” -
  • 2.1 β€” -
  • 3.0 β€” -
  • 3.1 β€” -
  • 3.2 β€” -
  • 3.3 β€” -
  • 4.0 β€” -
  • 4.1 β€” -
  • 4.2 β€” -
  • 4.3 β€” -
  • 4.4 β€” -
  • 4.5 β€” βœ”

so yeah. it's giving 4.5 exclusive. 4.5 only. nothing before it, not even a little. she arrived late and she ate πŸŽ€πŸ‘‘


πŸ“ SEE ALSO

go read these too, iykyk:

  • glCompressedTexImage1D()
  • glCompressedTexImage2D()
  • glCompressedTexImage3D()
  • glCompressedTexSubImage1D()
  • glCompressedTexSubImage2D()
  • glCompressedTexSubImage3D()
  • glGetCompressedTexImage()
  • glGetCompressedTextureImage
  • glReadPixels()

Copyright Β© 2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.

Copyright Β© 2014 Khronos Group


okay that's the whole page bestie, go forth and pull those compressed sub-images πŸ¦‹βœ¨

source: [FIXME: source] Β· dated 08/09/2021 Β· page GLGETCOMPRESSEDTEXTU(3G) β€” mwah, ily, drink some water πŸ’–πŸŽ€

πŸ“¦ where this page comes from