GLCOMPRESSEDTEXSUBIM(3G)

πŸ’… GLCOMPRESSEDTEXSUBIM(3G) β€” or, how to slide a compressed 3D subimage into your texture

okay bestie, sit down, because this whole page is literally about glCompressedTexSubImage3D and glCompressedTextureSubImage3D β€” two icons that let you swap out a chunk of an existing 3D texture with compressed data. the manual name is GLCOMPRESSEDTEXSUBIM(3G), iykyk. πŸŽ€


✨ NAME ✨

glCompressedTexSubImage3D, glCompressedTextureSubImage3D β€” specify a three-dimensional texture subimage in a compressed format. yes, that's the whole vibe. πŸ¦‹


🌸 C SPECIFICATION 🌸

here's the exact signature, do not touch, it's giving sacred text:

void glCompressedTexSubImage3D(GLenum target, GLint level,
                               GLint xoffset, GLint yoffset,
                               GLint zoffset, GLsizei width,
                               GLsizei height, GLsizei depth,
                               GLenum format, GLsizei imageSize,
                               const GLvoid * data);

void glCompressedTextureSubImage3D(GLuint texture, GLint level,
                                   GLint xoffset, GLint yoffset,
                                   GLint zoffset, GLsizei width,
                                   GLsizei height, GLsizei depth,
                                   GLenum format, GLsizei imageSize,
                                   const void *data);

πŸŽ€ PARAMETERS πŸŽ€

okay so every single one of these matters, no skipping πŸ™ˆ

  • target β€” the target the texture is bound to, for the glCompressedTexSubImage3D function. must be GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D, or GL_TEXTURE_CUBE_MAP_ARRAY. that's the whole list, periodt.
  • texture β€” the texture object name, for the glCompressedTextureSubImage3D function. main character energy.
  • level β€” the level-of-detail number. level 0 is the base image level. level n is the *n*th mipmap reduction image. tiny-to-big, iconic.
  • xoffset β€” a texel offset in the x direction within the texture array.
  • yoffset β€” a texel offset in the y direction within the texture array.
  • width β€” the width of the texture subimage.
  • height β€” the height of the texture subimage.
  • depth β€” the depth of the texture subimage. yes it goes in z too, we're three-dimensional here πŸ’…
  • format β€” the format of the compressed image data stored at address data.
  • imageSize β€” the number of unsigned bytes of image data starting at the address specified by data. count them. all of them.
  • data β€” a pointer to the compressed image data in memory. the moment.

πŸ’– DESCRIPTION πŸ’–

texturing allows elements of an image array to be read by shaders. that's the whole point, bestie, we're feeding the shaders. 🧚

glCompressedTexSubImage3D and glCompressedTextureSubImage3D redefine a contiguous subregion of an existing three-dimensional texture image. the texels referenced by data replace the portion of the existing texture array with:

  • x indices xoffset and xoffset + width - 1, and
  • y indices yoffset and yoffset + height - 1, and
  • z indices zoffset and zoffset + depth - 1,

inclusive. highkey it's just a rectangular glow-up for part of your texture. ✨

⚠️ this region may not include any texels outside the range of the texture array as it was originally specified. stay in your lane, subimage.

it is not an error to specify a subtexture with width of 0, but such a specification has no effect. literally nothing happens. a no-op. we respect that.

internalformat must be a known compressed image format (such as GL_RGTC) or an extension-specified compressed-texture format. the format of the compressed texture image is selected by the GL implementation that compressed it (see glTexImage3D()) and should be queried at the time the texture was compressed with glGetTexLevelParameter().

if a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target (see glBindBuffer()) while a texture image is specified, data is treated as a byte offset into the buffer object's data store. sneaky but true. 🫢


πŸ’€ ERRORS πŸ’€ (vibe check failed edition)

  • GL_INVALID_ENUM is generated if internalformat is one of the generic compressed internal formats: GL_COMPRESSED_RED, GL_COMPRESSED_RG, GL_COMPRESSED_RGB, GL_COMPRESSED_RGBA, GL_COMPRESSED_SRGB, or GL_COMPRESSED_SRGB_ALPHA. the generic ones are a no. πŸ™ˆ
  • GL_INVALID_ENUM is generated by glCompressedTexSubImage3D if target is not GL_TEXTURE_2D_ARRAY, GL_TEXTURE_3D, or GL_TEXTURE_CUBE_MAP_ARRAY.
  • GL_INVALID_OPERATION is generated by glCompressedTextureSubImage3D if texture is not the name of an existing texture object.
  • GL_INVALID_VALUE is generated if imageSize is not consistent with the format, dimensions, and contents of the specified compressed image data.
  • GL_INVALID_OPERATION is generated if parameter combinations are not supported by the specific compressed internal format as specified in the specific texture compression extension.
  • GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and the buffer object's data store is currently mapped.
  • GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.
  • Undefined results, including abnormal program termination, are generated if data is not encoded in a manner consistent with the extension specification defining the internal compression format. ⚠️ like, actual crashing. not cute. read the spec. 😭

πŸ”₯ ASSOCIATED GETS πŸ”₯

  • glGetCompressedTexImage()
  • glGet() with argument GL_TEXTURE_COMPRESSED
  • glGet() with argument GL_PIXEL_UNPACK_BUFFER_BINDING
  • glGetTexLevelParameter() with arguments GL_TEXTURE_INTERNAL_FORMAT and GL_TEXTURE_COMPRESSED_IMAGE_SIZE

πŸ‘‘ VERSION SUPPORT πŸ‘‘

so the original shipped this as a big table across OpenGL versions 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5 β€” here it is in list form because tables are not the vibe here, but the facts are identical, no cap:

  • glCompressedTexSubImage3D β€” βœ” in 2.0, βœ” in 2.1, βœ” in 3.0, βœ” in 3.1, βœ” in 3.2, βœ” in 3.3, βœ” in 4.0, βœ” in 4.1, βœ” in 4.2, βœ” in 4.3, βœ” in 4.4, βœ” in 4.5. she's been slaying since day one. πŸ‘‘
  • glCompressedTextureSubImage3D β€” - in 2.0, - in 2.1, - in 3.0, - in 3.1, - in 3.2, - in 3.3, - in 4.0, - in 4.1, - in 4.2, - in 4.3, - in 4.4, and βœ” in 4.5. late arrival, but she ate.

🌈 SEE ALSO 🌈

go read these next, bestie, they're all connected:

glActiveTexture(), glCompressedTexImage1D(), glCompressedTexImage2D(), glCompressedTexImage3D(), glCompressedTexSubImage1D(), glCompressedTexSubImage2D(), glCopyTexImage1D(), glCopyTexImage2D(), glCopyTexSubImage1D(), glCopyTexSubImage2D(), glCopyTexSubImage3D(), glPixelStore(), glTexImage2D(), glTexImage3D(), glTexSubImage1D(), glTexSubImage2D(), glTexSubImage3D(), glTexParameter()


Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.

Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group


and that's the page, babes 🫢 the footer said [FIXME: source] with the date 08/09/2021, so shoutout to whoever compiled this in August of 2021 β€” you're an icon, and a slightly unfinished one, and we love that for you. πŸ’œβœ¨

πŸ“¦ where this page comes from