GLGETTEXLEVELPARAMET(3G)

πŸ“¦
version 1.1 Β· 3 versions
, in centos-stream 9

πŸ’– GLGETTEXLEVELPARAMET(3G) πŸ’–

okay so bestie, this is the glGetTexLevelParameter page from the manual (the 3G one, for all you OpenGL girlies ✨). it's literally all about grabbing texture parameter values for a specific level of detail, and i'm gonna walk you through it so you actually get it. no cap, it's giving very detailed and very specific, but we're gonna slay this together πŸ’…


🌸 NAME 🌸

glGetTexLevelParameter β€” return texture parameter values for a specific level of detail, periodt.


✨ C SPECIFICATION ✨

here's the actual function signatures, and yes you need to copy them exactly, don't @ me:

void glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname,
                              GLfloat * params);

void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname,
                              GLint * params);

void glGetTextureLevelParameterfv(GLuint texture, GLint level,
                                  GLenum pname, GLfloat *params);

void glGetTextureLevelParameteriv(GLuint texture, GLint level,
                                  GLenum pname, GLint *params);

πŸŽ€ PARAMETERS πŸŽ€

okay so these are the arguments, and they're all main character energy:

  • target β€” specifies the target to which the texture is bound, but like ONLY for the glGetTexLevelParameterfv and glGetTexLevelParameteriv functions, iykyk. it has to be one of these values, no exceptions: GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_1D_ARRAY, GL_TEXTURE_2D_ARRAY, GL_TEXTURE_RECTANGLE, GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_2D_MULTISAMPLE_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, GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D, GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_1D_ARRAY, GL_PROXY_TEXTURE_2D_ARRAY, GL_PROXY_TEXTURE_RECTANGLE, GL_PROXY_TEXTURE_2D_MULTISAMPLE, GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY, GL_PROXY_TEXTURE_CUBE_MAP, or GL_TEXTURE_BUFFER.
  • texture β€” specifies the texture object name, but ONLY for the glGetTextureLevelParameterfv and glGetTextureLevelParameteriv functions. like, this one's for the texture-object girlies.
  • level β€” specifies the level-of-detail number of the desired image. level 0 is the base image level, and level n is the *n*th mipmap reduction image. so basically, it's the zoom level of your texture, and 0 is the OG.
  • pname β€” specifies the symbolic name of a texture parameter. these are the accepted ones: GL_TEXTURE_WIDTH, GL_TEXTURE_HEIGHT, GL_TEXTURE_DEPTH, GL_TEXTURE_INTERNAL_FORMAT, GL_TEXTURE_RED_SIZE, GL_TEXTURE_GREEN_SIZE, GL_TEXTURE_BLUE_SIZE, GL_TEXTURE_ALPHA_SIZE, GL_TEXTURE_DEPTH_SIZE, GL_TEXTURE_COMPRESSED, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, and GL_TEXTURE_BUFFER_OFFSET.
  • params β€” returns the requested data. it's where the function puts the tea β˜•.

πŸ¦‹ DESCRIPTION πŸ¦‹

so glGetTexLevelParameterfv, glGetTexLevelParameteriv, glGetTextureLevelParameterfv, and glGetTextureLevelParameteriv all return in params the texture parameter values for a specific level-of-detail value, specified as level. for the first two functions, target defines the target texture, and it's one of: GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D, GL_PROXY_TEXTURE_3D, 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, or GL_PROXY_TEXTURE_CUBE_MAP. the remaining two take a texture argument which specifies the name of the texture object.

now, GL_MAX_TEXTURE_SIZE and GL_MAX_3D_TEXTURE_SIZE are not really descriptive enough, and honestly? they're kinda flops for this. they have to report the largest square texture image that can be accommodated with mipmaps, but a long skinny texture, or a texture without mipmaps, may easily fit in texture memory. the proxy targets let you more accurately query whether the GL can accommodate a texture of a given configuration. if the texture cannot be accommodated, the texture state variables (which you can query with glGetTexLevelParameter and glGetTextureLevelParameter) are set to 0. if the texture can be accommodated, the texture state values will be set as they would be set for a non-proxy target. so proxy targets are like the vibe check for your texture 🫢

pname specifies the texture parameter whose value or values will be returned.

the accepted parameter names are as follows, and i'm gonna list every single one because we don't skip:

GL_TEXTURE_WIDTH

params returns a single value, the width of the texture image. the initial value is 0.

GL_TEXTURE_HEIGHT

params returns a single value, the height of the texture image. the initial value is 0.

GL_TEXTURE_DEPTH

params returns a single value, the depth of the texture image. the initial value is 0.

GL_TEXTURE_INTERNAL_FORMAT

params returns a single value, the internal format of the texture image.

GL_TEXTURE_RED_TYPE, GL_TEXTURE_GREEN_TYPE, GL_TEXTURE_BLUE_TYPE, GL_TEXTURE_ALPHA_TYPE, GL_TEXTURE_DEPTH_TYPE

the data type used to store the component. the types GL_NONE, GL_SIGNED_NORMALIZED, GL_UNSIGNED_NORMALIZED, GL_FLOAT, GL_INT, and GL_UNSIGNED_INT may be returned to indicate signed normalized fixed-point, unsigned normalized fixed-point, floating-point, integer unnormalized, and unsigned integer unnormalized components, respectively. so it's literally telling you what kind of data you're working with πŸ’…

GL_TEXTURE_RED_SIZE, GL_TEXTURE_GREEN_SIZE, GL_TEXTURE_BLUE_SIZE, GL_TEXTURE_ALPHA_SIZE, GL_TEXTURE_DEPTH_SIZE

the internal storage resolution of an individual component. the resolution chosen by the GL will be a close match for the resolution requested by the user with the component argument of glTexImage1D(), glTexImage2D(), glTexImage3D(), glCopyTexImage1D(), and glCopyTexImage2D(). the initial value is 0.

GL_TEXTURE_COMPRESSED

params returns a single boolean value indicating if the texture image is stored in a compressed internal format. the initiali value (yes, that's how it's spelled in the original, don't come for me 😭) is GL_FALSE.

GL_TEXTURE_COMPRESSED_IMAGE_SIZE

params returns a single integer value, the number of unsigned bytes of the compressed texture image that would be returned from glGetCompressedTexImage().

GL_TEXTURE_BUFFER_OFFSET

params returns a single integer value, the offset into the data store of the buffer bound to a buffer texture. that's glTexBufferRange().

GL_TEXTURE_BUFFER_SIZE

params returns a single integer value, the size of the range of a data store of the buffer bound to a buffer texture. also glTexBufferRange().


πŸ”₯ NOTES πŸ”₯

  • if an error is generated, no change is made to the contents of params. so your data stays safe, bestie.
  • glGetTexLevelParameter returns the texture level parameters for the active texture unit. it's the one that knows what unit you're on.
  • GL_TEXTURE_BUFFER_OFFSET and GL_TEXTURE_BUFFER_SIZE are available only if the GL version is 4.3 or greater. so if you're on an older GL, these are a no-go.

πŸ’€ ERRORS πŸ’€

okay so here's where stuff can go wrong, and you need to know:

  • GL_INVALID_OPERATION is generated by glGetTextureLevelParameterfv and glGetTextureLevelParameteriv functions if texture is not the name of an existing texture object. so like, if you're referencing a texture that doesn't exist, it's giving invalid operation.
  • GL_INVALID_ENUM is generated by glGetTexLevelParameterfv and glGetTexLevelParameteriv functions if target or pname is not an accepted value. so don't be out here using random enums.
  • GL_INVALID_VALUE is generated if level is less than 0. negative levels are not the vibe.
  • GL_INVALID_VALUE may be generated if level is greater than log 2 max, where max is the returned value of GL_MAX_TEXTURE_SIZE. so highkey watch out for that.
  • GL_INVALID_VALUE is generated if target is GL_TEXTURE_BUFFER and level is not zero. so buffer textures only accept level 0, periodt.
  • GL_INVALID_OPERATION is generated if GL_TEXTURE_COMPRESSED_IMAGE_SIZE is queried on texture images with an uncompressed internal format or on proxy targets. so don't ask for compressed size on an uncompressed image, it's not gonna happen.

πŸ‘‘ VERSION SUPPORT πŸ‘‘

okay so the original had this whole table, and i'm gonna give it to you in a way that's still accurate but way cuter. here's which functions are supported in which OpenGL versions:

  • glGetTexLevelParameterfv β€” available in 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5. it's literally everywhere, an icon.
  • glGetTexLevelParameteriv β€” available in 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5. same energy.
  • glGetTextureLevelParameterfv β€” available ONLY in 4.5. it's a late bloomer, but we respect it.
  • glGetTextureLevelParameteriv β€” available ONLY in 4.5. also a 4.5 exclusive.

so if you're on anything below 4.5, the texture-object versions are not for you.


🌈 SEE ALSO 🌈

like all good things, this page connects to others. go check these out:

  • glActiveTexture()
  • glGetTexParameter()
  • glCopyTexImage1D()
  • glCopyTexImage2D()
  • glCopyTexSubImage1D()
  • glCopyTexSubImage2D()
  • glCopyTexSubImage3D()
  • glTexImage1D()
  • glTexImage2D()
  • glTexImage3D()
  • glTexSubImage1D()
  • glTexSubImage2D()
  • glTexSubImage3D()
  • glTexParameter()

this is important, so i'm keeping it exact:

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 Β© 2014 Khronos Group


and that's the whole page, bestie! you're now a glGetTexLevelParameter expert, no cap. go forth and query those texture levels like the main character you are πŸ’–βœ¨

so this page came from [FIXME: source] and was dated 08/09/2021 β€” big throwback energy, but we still slayed it. mwah! 🫢

πŸ“¦ where this page comes from