GLGETCOMPRESSEDTEXIM(3G)
π GLGETCOMPRESSEDTEXIM(3G) β return a compressed texture image π
okay so first things first, bestie: this is from the 3G manual, and it's literally the glow-up you need when you wanna pull a compressed texture image out of OpenGL. no cap, it's giving "I know what I'm doing" energy. let's get into it π«Ά
β¨ C SPECIFICATION β¨
here's the tea, three whole function signatures, copy them exactly because bestie we do not freestyle signatures:
void glGetCompressedTexImage(GLenum target, GLint level,
GLvoid * pixels);
void glGetnCompressedTexImage(GLenum target, GLint level,
GLsizei bufSize, void *pixels);
void glGetCompressedTextureImage(GLuint texture, GLint level,
GLsizei bufSize, void *pixels);
πΈ PARAMETERS πΈ
targetβ this is the target the texture is bound to forglGetCompressedTexImageandglGetnCompressedTexImage. accepted targets are:GL_TEXTURE_1D,GL_TEXTURE_1D_ARRAY,GL_TEXTURE_2D,GL_TEXTURE_2D_ARRAY,GL_TEXTURE_3D,GL_TEXTURE_CUBE_MAP_ARRAY,GL_TEXTURE_CUBE_MAP_POSITIVE_X,GL_TEXTURE_CUBE_MAP_NEGATIVE_X,GL_TEXTURE_CUBE_MAP_POSITIVE_Y,GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,GL_TEXTURE_CUBE_MAP_POSITIVE_Z,GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, andGL_TEXTURE_RECTANGLE. yes bestie, all thirteen of them, I counted πtextureβ specifies the texture object name for theglGetCompressedTextureImagefunction. like, the actual ID of the texture, not the target. iconic distinction fr fr.levelβ the level-of-detail number of the desired image. level0is the base image level. level n is the n-th mipmap reduction image. mipmap math, we love to see it β¨bufSizeβ specifies the size of the bufferpixelsforglGetCompressedTextureImageandglGetnCompressedTexImagefunctions. it's giving "how much room do I have" energy.pixelsβ returns the compressed texture image. that's the whole point, bestie π
π¦ DESCRIPTION π¦
so glGetCompressedTexImage and glGetnCompressedTexImage return the compressed texture image associated with target and lod into pixels. glGetCompressedTextureImage serves the same purpose, but instead of taking a texture target, it takes the ID of the texture object. slay.
pixels should be an array of bufSize bytes for glGetnCompresedTexImage and glGetCompressedTextureImage functions, and of GL_TEXTURE_COMPRESSED_IMAGE_SIZE bytes in case of glGetCompressedTexImage. (yes, that's literally how it's spelled in the original, glGetnCompresedTexImage with no second 's', I'm not fixing it, I'm just delivering it exactly as it is π)
if the actual data takes less space than bufSize, the remaining bytes will not be touched. periodt. don't come for me.
target specifies the texture target, to which the texture the data the function should extract the data from is bound to. (that sentence is a lot, but it's the original, okay? it means: the texture you want data from must be bound to target.)
lod specifies the level-of-detail number of the desired image.
if a non-zero named buffer object is bound to the GL_PIXEL_PACK_BUFFER target (see glBindBuffer()) while a texture image is requested, pixels is treated as a byte offset into the buffer object's data store. like, it's not a pointer anymore, it's an offset. glow-up moment.
to minimize errors, here's the responsible bestie checklist β and I'm quoting the steps exactly because this is important:
- first verify that the texture is compressed by calling
glGetTexLevelParameter()with argumentGL_TEXTURE_COMPRESSED. - if the texture is compressed, you can determine the amount of memory required to store the compressed texture by calling
glGetTexLevelParameter()with argumentGL_TEXTURE_COMPRESSED_IMAGE_SIZE. - finally, retrieve the internal format of the texture by calling
glGetTexLevelParameter()with argumentGL_TEXTURE_INTERNAL_FORMAT.
to store the texture for later use, associate the internal format and size with the retrieved texture image. these data can be used by the respective texture or subtexture loading routine used for loading target textures. iykyk π§
π ERRORS π
okay so here's where it can go wrong, and we do not want that:
GL_INVALID_OPERATIONis generated byglGetCompressedTextureImageiftextureis not the name of an existing texture object.GL_INVALID_VALUEis generated iflevelis less than zero or greater than the maximum number of LODs permitted by the implementation.GL_INVALID_OPERATIONis generated ifglGetCompressedTexImage,glGetnCompressedTexImage, andglGetCompressedTextureImageis used to retrieve a texture that is in an uncompressed internal format. (yes, uncompressed = invalid operation, don't do it bestie π)GL_INVALID_OPERATIONis generated if a non-zero buffer object name is bound to theGL_PIXEL_PACK_BUFFERtarget, the buffer storage was not initialized withglBufferStorageusingGL_MAP_PERSISTENT_BITflag, and the buffer object's data store is currently mapped.GL_INVALID_OPERATIONis generated if a non-zero buffer object name is bound to theGL_PIXEL_PACK_BUFFERtarget and the data would be packed to the buffer object such that the memory writes required would exceed the data store size. oop, buffer overflow vibes, not the good kind.
β ASSOCIATED GETS β
these are the gets that go with it, like accessories but for OpenGL:
glGetTexLevelParameter()with argumentGL_TEXTURE_COMPRESSEDglGetTexLevelParameter()with argumentGL_TEXTURE_COMPRESSED_IMAGE_SIZEglGetTexLevelParameter()with argumentGL_TEXTURE_INTERNAL_FORMATglGet()with argumentGL_PIXEL_PACK_BUFFER_BINDING
π VERSION SUPPORT π
here's the whole vibe check, exactly as it appears β I'm putting it in a code block so nothing gets lost in translation:
βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β OpenGL Version β
βββββββββββββββββββββββββββββββΌββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ¬ββββββ€
β Function β 2.0 β 2.1 β 3.0 β 3.1 β 3.2 β 3.3 β 4.0 β 4.1 β 4.2 β 4.3 β 4.4 β 4.5 β
β / β β β β β β β β β β β β β
β Feature β β β β β β β β β β β β β
β Name β β β β β β β β β β β β β
βββββββββββββββββββββββββββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββ€
β glGetCompressedTexImage β β β β β β β β β β β β β β β β β β β β β β β β β
βββββββββββββββββββββββββββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββ€
β glGetCompressedTextureImage β - β - β - β - β - β - β - β - β - β - β - β β β
βββββββββββββββββββββββββββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββΌββββββ€
β glGetnCompressedTexImage β - β - β - β - β - β - β - β - β - β - β - β β β
βββββββββββββββββββββββββββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ΄ββββββ
like, glGetCompressedTexImage has been iconic since OpenGL 2.0, and the other two are 4.5-only. main character energy vs. new girl on the block, no shade π
π SEE ALSO π
go check these out, they're all related and honestly kind of a mood:
glActiveTexture(), glCompressedTexImage1D(), glCompressedTexImage2D(), glCompressedTexImage3D(), glCompressedTexSubImage1D(), glCompressedTexSubImage2D(), glCompressedTexSubImage3D(), glReadPixels(), glTexImage1D(), glTexImage2D(), glTexImage3D(), glTexParameter(), glTexSubImage1D(), glTexSubImage2D(), glTexSubImage3D()
π COPYRIGHT π
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://opencontent.org/openpub/.
Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2010-2014 Khronos Group
and that's the whole page, bestie! π source is literally [FIXME: source] and the date is 08/09/2021, so like, this manual is vintage but still valid. go get those compressed textures, you've got this πβ¨
π¦ where this page comes from
- centos-stream 9: gl-manpages 1.1-24.20190306.el9 Β· MIT and Open Publication
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms