GLGETINTERNALFORMAT(3G)
π glGetInternalformat β the 3G manual page, but make it make sense π
okay so bestie, welcome to section 3G, aka the glGetInternalformat page. this one's all about "retrieve information about implementation-dependent support for internal formats" β which is a fancy way of saying: you ask your GL implementation "hey, what can you actually do with this internal format on this target?" and it tells you. no cap, it's giving very much "let me check with my manager" energy. π
β¨ NAME β¨
glGetInternalformat β retrieve information about implementation-dependent support for internal formats πΈ
π§Ύ C SPECIFICATION
two flavours, bestie. one for regular ints, one for the 64-bit girlies:
void glGetInternalformativ(GLenum target, GLenum internalformat,
GLenum pname, GLsizei bufSize,
GLint *params);
void glGetInternalformati64v(GLenum target, GLenum internalformat,
GLenum pname, GLsizei bufSize,
GLint64 *params);
π PARAMETERS π
targetβ tells the function how this internal format is gonna be used. 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,GL_TEXTURE_RECTANGLE,GL_TEXTURE_BUFFER,GL_RENDERBUFFER,GL_TEXTURE_2D_MULTISAMPLEorGL_TEXTURE_2D_MULTISAMPLE_ARRAY. like, pick your lane, babe β¨internalformatβ specifies the internal format you want the tea about. π΅pnameβ specifies the type of information you're querying. this is the "what do you wanna know" knob.bufSizeβ the max number of integers (of the specified width) that may be written toparamsby the function. safety scissors for your buffer. π«Άparamsβ the address of the variable where the retrieved info gets written. this is where the answers land.
π DESCRIPTION π
so glGetInternalformativ and glGetInternalformati64v retrieve information about implementation-dependent support for internal formats. iconique. π
target indicates the target with which the internal format will be used and must be one of GL_RENDERBUFFER, GL_TEXTURE_2D_MULTISAMPLE, or GL_TEXTURE_2D_MULTISAMPLE_ARRAY β corresponding to usage as a renderbuffer, two-dimensional multisample texture, or two-dimensional multisample array texture, respectively.
ok so real talk: that's literally what this paragraph says, and yes, the target list up in PARAMETERS is way longer. the manpage said both things, so here we are. keeping it exactly as given, bestie. no notes. π
internalformat specifies the internal format about which to retrieve information, and it must be a color-renderable, depth-renderable or stencil-renderable format.
the info retrieved gets written to the memory addressed by the pointer specified in params. no more than bufSize integers will be written to that memory β so don't get cute and assume it'll overflow for you. π
π’ the sample-count queries
if pname is GL_NUM_SAMPLE_COUNTS, then the number of sample counts that would be returned by querying GL_SAMPLES is returned in params.
if pname is GL_SAMPLES, the sample counts supported for internalformat and target are written into params in descending numeric order. only positive values are returned. π
querying GL_SAMPLES with a bufSize of one will return just the maximum supported number of samples for this format. and heads up β the maximum value in GL_SAMPLES is guaranteed to be at least the lowest of the following:
- the value of
GL_MAX_INTEGER_SAMPLESifinternalformatis a signed or unsigned integer format. - the value of
GL_MAX_DEPTH_TEXTURE_SAMPLESifinternalformatis a depth- or stencil-renderable format andtargetisGL_TEXTURE_2D_MULTISAMPLE,GL_TEXTURE_2D_MULTISAMPLE_ARRAY. - the value of
GL_MAX_COLOR_TEXTURE_SAMPLESifinternalformatis a color-renderable format andtargetisGL_TEXTURE_2D_MULTISAMPLEorGL_TEXTURE_2D_MULTISAMPLE_ARRAY. - the value of
GL_MAX_SAMPLES.
lowkey the "lowest of the following" phrasing is sending me, but it's precise and we respect it. π
π§ supported / preferred
if pname is GL_INTERNALFORMAT_SUPPORTED, params is set to GL_TRUE if internalformat is a supported internal format for target, and to GL_FALSE otherwise.
if pname is GL_INTERNALFORMAT_PREFERRED, params is set to GL_TRUE if internalformat is an format for target that is preferred by the implementation, and to GL_FALSE otherwise.
π component sizes
if pname is GL_INTERNALFORMAT_RED_SIZE, GL_INTERNALFORMAT_GREEN_SIZE, GL_INTERNALFORMAT_BLUE_SIZE, GL_INTERNALFORMAT_ALPHA_SIZE, GL_INTERNALFORMAT_DEPTH_SIZE, GL_INTERNALFORMAT_STENCIL_SIZE, or GL_INTERNALFORMAT_SHARED_SIZE, then params is set to the actual resolutions that would be used for storing image array components for the resource, for the red, green, blue, alpha, depth, stencil and shared channels respectively.
if internalformat is a compressed internal format, then params is set to the component resolution of an uncompressed internal format that produces an image of roughly the same quality as the compressed algorithm. if the internal format is unsupported, or if a particular component is not present in the format, 0 is written to params. zero. nada. nothing for you. π
π·οΈ component types
if pname is GL_INTERNALFORMAT_RED_TYPE, GL_INTERNALFORMAT_GREEN_TYPE, GL_INTERNALFORMAT_BLUE_TYPE, GL_INTERNALFORMAT_ALPHA_TYPE, GL_INTERNALFORMAT_DEPTH_TYPE, or GL_INTERNALFORMAT_STENCIL_TYPE, then params is set to a token identifying the data type used to store the respective component.
if the internalformat represents a compressed internal format then the types returned specify how components are interpreted after decompression. pop off, decompression β¨
π dimensions
if pname is GL_MAX_WIDTH, GL_MAX_HEIGHT, GL_MAX_DEPTH, or GL_MAX_LAYERS, then it's filled with the maximum width, height, depth or layer count for textures with internal format internalformat, respectively.
if pname is GL_MAX_COMBINED_DIMENSIONS, then it's filled with the maximum combined dimensions of a texture of the specified internal format.
π which components even exist
if pname is GL_COLOR_COMPONENTS, then params is set to GL_TRUE if the internal format contains any color component (i.e. red, green, blue or alpha), and to GL_FALSE otherwise.
if pname is GL_DEPTH_COMPONENTS or GL_STENCIL_COMPONENTS, then params is set to GL_TRUE if the internal format contains a depth or stencil component, respectively, and to GL_FALSE otherwise.
π«Ά renderable-ness
if pname is GL_COLOR_RENDERABLE, GL_DEPTH_RENDERABLE or GL_STENCIL_RENDERABLE, then params is set to GL_TRUE if the specified internal format is color, depth or stencil renderable, respectively, and to GL_FALSE otherwise.
if pname is GL_FRAMEBUFFER_RENDERABLE or GL_FRAMEBUFFER_RENDERABLE_LAYERED, then params is set to one of GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT or GL_NONE, to indicate that framebuffer attachments (layered attachments in the case of GL_FRAMEBUFFER_RENDERABLE_LAYERED) with that internal format are either renderable with no restrictions, renderable with some restrictions, or not renderable at all. it's giving "yes", "yes but read the fine print", and "absolutely not". π
if pname is GL_FRAMEBUFFER_BLEND, params is set to GL_TRUE to indicate that the internal format is supported for blending operations when attached to a framebuffer, and to GL_FALSE otherwise.
π reading pixels
if pname is GL_READ_PIXELS, then params is set to GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT or GL_NONE, to indicate that either full support, limited support or no support at all is supplied for reading pixels from framebuffer attachments in the specified internal format.
if pname is GL_READ_PIXELS_FORMAT or GL_READ_PIXELS_TYPE, then params is filled with the format or type, respectively, most recommended to obtain the highest image quality and performance. π₯
- for
GL_READ_PIXELS_FORMAT, the value returned inparamsis a token that is accepted for theformatargument toglReadPixels(). - for
GL_READ_PIXELS_TYPE, the value returned inparamsis a token that is accepted for thetypeargument toglReadPixels().
π¦ texture image formats and types
if pname is GL_TEXTURE_IMAGE_FORMAT or GL_TEXTURE_IMAGE_TYPE, then params is filled with the implementation-recommended format or type to be used in calls to glTexImage2D() and other similar functions.
- for
GL_TEXTURE_IMAGE_FORMAT,paramsis filled with a token suitable for use as theformatargument toglTexImage2D(). - for
GL_TEXTURE_IMAGE_TYPE,paramsis filled with a token suitable for use as thetypeargument toglTexImage2D().
if pname is GL_GET_TEXTURE_IMAGE_FORMAT or GL_GET_TEXTURE_IMAGE_TYPE, then params is filled with the implementation-recommended format or type to be used in calls to glGetTexImage() and other similar functions.
- for
GL_GET_TEXTURE_IMAGE_FORMAT,paramsis filled with a token suitable for use as theformatargument toglGetTexImage(). - for
GL_GET_TEXTURE_IMAGE_TYPE,paramsis filled with a token suitable for use as thetypeargument toglGetTexImage().
β mipmaps
if pname is GL_MIPMAP, it's set to GL_TRUE to indicate that the specified internal format supports mipmaps, and to GL_FALSE otherwise.
if pname is GL_GENERATE_MIPMAP or GL_AUTO_GENERATE_MIPMAP, then params indicates the level of support for manual or automatic mipmap generation for the specified internal format, respectively. returned values may be one of GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT and GL_NONE, to indicate either full support, limited support or no support at all.
πΈ color encoding
if pname is GL_COLOR_ENCODING, then the color encoding for the resource is returned in params. possible values for color buffers are GL_LINEAR or GL_SRGB, for linear or sRGB-encoded color components, respectively. for non-color formats (such as depth or stencil), or for unsupported resources, the value GL_NONE is returned.
π§ sRGB read/write
if pname is GL_SRGB_READ, or GL_SRGB_WRITE, then params indicates the level of support for reading and writing to sRGB encoded images, respectively.
- for
GL_SRGB_READ, support for converting from sRGB colorspace on read operations is returned inparams. - for
GL_SRGB_WRITE, support for converting to sRGB colorspace on write operations to the resource is returned inparams.
params may be set to GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT, or GL_NONE, to indicate full support, limited support or no support at all, respectively. π
π filtering
if pname is GL_FILTER, then params is set to either GL_TRUE or GL_FALSE to indicate support or lack thereof for filter modes other than GL_NEAREST or GL_NEAREST_MIPMAP for the specified internal format.
π shader stage support
if pname is GL_VERTEX_TEXTURE, GL_TESS_CONTROL_TEXTURE, GL_TESS_EVALUATION_TEXTURE, GL_GEOMETRY_TEXTURE, GL_FRAGMENT_TEXTURE, or GL_COMPUTE_TEXTURE, then the value written to params indicates support for use of the resource as a source of texturing in the vertex, tessellation control, tessellation evaluation, geometry, fragment and compute shader stages, respectively. params may be set to GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT or GL_NONE, to indicate full support, limited support or no support at all, respectively.
π shadow + gather
if pname is GL_TEXTURE_SHADOW, GL_TEXTURE_GATHER or GL_TEXTURE_GATHER_SHADOW, then the value written to params indicates the level of support for using the resource with a shadow sampler, in gather operations, or as a shadow sampler in gather operations, respectively. returned values may be GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT or GL_NONE, to indicate full support, limited support or no support at all, respectively.
π₯ shader image load/store/atomic
if pname is GL_SHADER_IMAGE_LOAD, GL_SHADER_IMAGE_STORE or GL_SHADER_IMAGE_ATOMIC, then the value returned in params indicates the level of support for image loads, stores and atomics for resources of the specified internal format. returned values may be GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT or GL_NONE, to indicate full support, limited support or no support at all, respectively.
If pname is GL_IMAGE_TEXEL_SIZE, bestie you get the size of a texel when the resource is used as an image texture, dropped right into params. And if the resource isn't supported for image textures? Zero. Big fat 0. π
If pname is GL_IMAGE_COMPATIBILITY_CLASS, then params gets the compatibility class of the resource when it's used as an image texture. The possible values coming back are GL_IMAGE_CLASS_4_X_32, GL_IMAGE_CLASS_2_X_32, GL_IMAGE_CLASS_1_X_32, GL_IMAGE_CLASS_4_X_16, GL_IMAGE_CLASS_2_X_16, GL_IMAGE_CLASS_1_X_16, GL_IMAGE_CLASS_4_X_8, GL_IMAGE_CLASS_2_X_8, GL_IMAGE_CLASS_1_X_8, GL_IMAGE_CLASS_11_11_10, and GL_IMAGE_CLASS_10_10_10_2 β and those correspond to the 4x32, 2x32, 1x32, 4x16, 2x16, 1x16, 4x8, 2x8, 1x8, the class (a) 11/11/10 packed floating-point format, and the class (b) 10/10/10/2 packed formats, respectively (in that order, obvi). If the resource isn't supported for image textures, you get GL_NONE. β¨
If pname is GL_IMAGE_PIXEL_FORMAT or GL_IMAGE_PIXEL_TYPE, then you get the pixel format or the pixel type of the resource when used as an image texture, respectively, in params. In either case, if the resource isn't supported for image textures, GL_NONE is returned. π«Ά
If pname is GL_IMAGE_FORMAT_COMPATIBILITY_TYPE, the matching criteria used for the resource when it's used as an image texture is returned in params. Possible values in params are GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE or GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS. If the resource isn't supported for image textures, GL_NONE is returned. π
If pname is GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST or GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST, then support for using the resource both as a source for texture sampling while it's bound as a buffer for depth or stencil test (respectively) gets written to params. Possible values are GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT, or GL_NONE β meaning full support, limited support, or no support at all. If the resource or operation isn't supported, GL_NONE is returned. πΈ
If pname is GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE or GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE, then support for using the resource both as a source for texture sampling while performing depth or stencil writes to the resources (respectively) is written to params. Possible values are GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT, or GL_NONE β full support, limited support, no support at all. If the resource or operation isn't supported, GL_NONE is returned. π
If pname is GL_TEXTURE_COMPRESSED, you get GL_TRUE in params if internalformat is a compressed internal format. Otherwise params gets GL_FALSE. π
If pname is GL_TEXTURE_COMPRESSED_BLOCK_WIDTH, GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT or GL_TEXTURE_COMPRESSED_BLOCK_SIZE, then the width, height, or total size of a block (in basic machine units) respectively goes into params. If the internal format isn't compressed, or the resource isn't supported, you get 0. π
If pname is GL_CLEAR_BUFFER, the level of support for using the resource with glClearBufferData() and glClearBufferSubData() is returned in params. Possible values are GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT, or GL_NONE β full support, limited support, or no support at all, respectively. If the resource or operation isn't supported, GL_NONE is returned. π₯
If pname is GL_TEXTURE_VIEW, the level of support for using the resource with the glTextureView() command comes back in params. Possible values: GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT, or GL_NONE β full support, limited support, no support at all, respectively. If the resource or operation isn't supported, GL_NONE is returned. β¨
If pname is GL_VIEW_COMPATIBILITY_CLASS, then params gets the compatibility class of the resource when it's used as a texture view. The possible values returned are GL_VIEW_CLASS_128_BITS, GL_VIEW_CLASS_96_BITS, GL_VIEW_CLASS_64_BITS, GL_VIEW_CLASS_48_BITS, GL_VIEW_CLASS_32_BITS, GL_VIEW_CLASS_24_BITS, GL_VIEW_CLASS_16_BITS, GL_VIEW_CLASS_8_BITS, GL_VIEW_CLASS_S3TC_DXT1_RGB, GL_VIEW_CLASS_S3TC_DXT1_RGBA, GL_VIEW_CLASS_S3TC_DXT3_RGBA, GL_VIEW_CLASS_S3TC_DXT5_RGBA, GL_VIEW_CLASS_RGTC1_RED, GL_VIEW_CLASS_RGTC2_RG, GL_VIEW_CLASS_BPTC_UNORM, and GL_VIEW_CLASS_BPTC_FLOAT. π
If pname is GL_CLEAR_TEXTURE, then the presence of support for using the glClearTexImage() and glClearTexSubImage() commands with the resource gets written to params. Possible values written are GL_FULL_SUPPORT, GL_CAVEAT_SUPPORT, or GL_NONE β full support, limited support, or no support at all, respectively. If the resource or operation isn't supported, GL_NONE is returned. π
π NOTES
Okay so real talk: glGetInternalformativ only exists if your GL version is 4.2 or higher. No cap. If you're on something older, this whole thing is giving "not for you". π
And listen β these tokens:
GL_INTERNALFORMAT_SUPPORTED, GL_INTERNALFORMAT_PREFERRED, GL_INTERNALFORMAT_RED_SIZE, GL_INTERNALFORMAT_GREEN_SIZE, GL_INTERNALFORMAT_BLUE_SIZE, GL_INTERNALFORMAT_ALPHA_SIZE, GL_INTERNALFORMAT_DEPTH_SIZE, GL_INTERNALFORMAT_STENCIL_SIZE, GL_INTERNALFORMAT_SHARED_SIZE, GL_INTERNALFORMAT_RED_TYPE, GL_INTERNALFORMAT_GREEN_TYPE, GL_INTERNALFORMAT_BLUE_TYPE, GL_INTERNALFORMAT_ALPHA_TYPE, GL_INTERNALFORMAT_DEPTH_TYPE, GL_INTERNALFORMAT_STENCIL_TYPE, GL_MAX_WIDTH, GL_MAX_HEIGHT, GL_MAX_DEPTH, GL_MAX_LAYERS, GL_MAX_COMBINED_DIMENSIONS, GL_COLOR_COMPONENTS, GL_DEPTH_COMPONENTS, GL_STENCIL_COMPONENTS, GL_COLOR_RENDERABLE, GL_DEPTH_RENDERABLE, GL_STENCIL_RENDERABLE, GL_FRAMEBUFFER_RENDERABLE, GL_FRAMEBUFFER_RENDERABLE_LAYERED, GL_FRAMEBUFFER_BLEND, GL_READ_PIXELS, GL_READ_PIXELS_FORMAT, GL_READ_PIXELS_TYPE, GL_TEXTURE_IMAGE_FORMAT, GL_TEXTURE_IMAGE_TYPE, GL_GET_TEXTURE_IMAGE_FORMAT, GL_GET_TEXTURE_IMAGE_TYPE, GL_MIPMAP, GL_GENERATE_MIPMAP, GL_AUTO_GENERATE_MIPMAP, GL_COLOR_ENCODING, GL_SRGB_READ, GL_SRGB_WRITE, GL_SRGB_DECODE_ARB, GL_FILTER, GL_VERTEX_TEXTURE, GL_TESS_CONTROL_TEXTURE, GL_TESS_EVALUATION_TEXTURE, GL_GEOMETRY_TEXTURE, GL_FRAGMENT_TEXTURE, GL_COMPUTE_TEXTURE, GL_TEXTURE_SHADOW, GL_TEXTURE_GATHER, GL_TEXTURE_GATHER_SHADOW, GL_SHADER_IMAGE_LOAD, GL_SHADER_IMAGE_STORE, GL_SHADER_IMAGE_ATOMIC, GL_IMAGE_TEXEL_SIZE, GL_IMAGE_COMPATIBILITY_CLASS, GL_IMAGE_PIXEL_FORMAT, GL_IMAGE_PIXEL_TYPE, GL_IMAGE_FORMAT_COMPATIBILITY_TYPE, GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST, GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST, GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE, GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE, GL_TEXTURE_COMPRESSED, GL_TEXTURE_COMPRESSED_BLOCK_WIDTH, GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT, GL_TEXTURE_COMPRESSED_BLOCK_SIZE, GL_CLEAR_BUFFER, GL_TEXTURE_VIEW, and GL_VIEW_COMPATIBILITY_CLASS
β all of those are supported only if the GL version is 4.3 or higher. Like, the whole glow-up squad showed up in 4.3. π¦
Also, the GL_CLEAR_TEXTURE token is accepted for pname only if the GL version is 4.4 or higher. That one's a late arrival, iconic but late. β
π¨ ERRORS
Okay so here's where things get spicy β these are the ways you can mess up, bestie, so pay attention:
GL_INVALID_VALUEis generated ifbufSizeis negative. (Negative size?? be so fr. π)GL_INVALID_ENUMis generated ifpnameis notGL_SAMPLESorGL_NUM_SAMPLE_COUNTS.GL_INVALID_ENUMis generated ifinternalformatis not color-, depth-, or stencil-renderable.GL_INVALID_ENUMis generated iftargetis not one ofGL_TEXTURE_2D_MULTISAMPLE,GL_TEXTURE_2D_MULTISAMPLE_ARRAYorGL_RENDERBUFFER.
π«Ά none of these are cute and none of them are recoverable-by-vibes. handle them properly.
π VERSION SUPPORT
The original ships a whole grid of β and -, and here's that same tea in list form, because tables are not the moment in a terminal. The columns go 2.0, 2.1, 3.0, 3.1, 3.2, 3.3, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5.
glGetInternalformati64v
2.0:-2.1:-3.0:-3.1:-3.2:-3.3:-4.0:-4.1:-4.2:-4.3: β4.4: β4.5: β
glGetInternalformativ
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 like, glGetInternalformati64v is the 4.3+ baddie, and glGetInternalformativ started serving looks in 4.2. Slay. π
π¦ SEE ALSO
glGet()β the OG, the main character, the one everybody already knows. π
π COPYRIGHT
Copyright Β© 2011-2018 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/ β yes, the whole link, keep it, it's load-bearing. π«Ά
Copyright Β© 2011-2014 Khronos Group.
Okurrr and that's the whole page, bestie β no notes, no crumbs. The original footer is GLGETINTERNALFORMAT(3G) (the source field literally says [FIXME: source], which, mood, honestly β someone left a TODO in the header and I respect the honesty π), and it's dated 08/09/2021. Go forth and query those internal formats. πβ¨ππ¦
π¦ 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