GLTEXIMAGE3D(3G)
π NAME π
glTexImage3D β specify a three-dimensional texture image β¨
okay so bestie, this is the GLTEXIMAGE3D(3G) page from the [FIXME: manual] manual, and it's literally all about glTexImage3D β the function that says βhere's a whole 3D texture image, pls take it.β π«Ά
β¨ C SPECIFICATION β¨
void glTexImage3D(GLenum target, GLint level, GLint internalformat,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type,
const GLvoid * data);
π PARAMETERS π
targetβ which texture target you're aiming at, bestie. Must be one ofGL_TEXTURE_3D,GL_PROXY_TEXTURE_3D,GL_TEXTURE_2D_ARRAY, orGL_PROXY_TEXTURE_2D_ARRAY. π―levelβ the level-of-detail number. Level0is the base image level, and levelnis thenth mipmap reduction image. no cap. πͺinternalformatβ specifies the number of color components in the texture. Must be one of the base internal formats given in Table 1, one of the sized internal formats given in Table 2, or one of the compressed internal formats given in Table 3, below. πwidthβ the width of the texture image. All implementations support 3D texture images that are at least16texels wide. πheightβ the height of the texture image. All implementations support 3D texture images that are at least256texels high. πdepthβ the depth of the texture image, or the number of layers in a texture array. All implementations support 3D texture images that are at least256texels deep, and texture arrays that are at least256layers deep. π§borderβ this value must be0. periodt. π«formatβ the format of the pixel data. The following symbolic values are accepted:GL_RED,GL_RG,GL_RGB,GL_BGR,GL_RGBA,GL_BGRA,GL_RED_INTEGER,GL_RG_INTEGER,GL_RGB_INTEGER,GL_BGR_INTEGER,GL_RGBA_INTEGER,GL_BGRA_INTEGER,GL_STENCIL_INDEX,GL_DEPTH_COMPONENT,GL_DEPTH_STENCIL. π¨typeβ the data type of the pixel data. The following symbolic values are accepted:GL_UNSIGNED_BYTE,GL_BYTE,GL_UNSIGNED_SHORT,GL_SHORT,GL_UNSIGNED_INT,GL_INT,GL_HALF_FLOAT,GL_FLOAT,GL_UNSIGNED_BYTE_3_3_2,GL_UNSIGNED_BYTE_2_3_3_REV,GL_UNSIGNED_SHORT_5_6_5,GL_UNSIGNED_SHORT_5_6_5_REV,GL_UNSIGNED_SHORT_4_4_4_4,GL_UNSIGNED_SHORT_4_4_4_4_REV,GL_UNSIGNED_SHORT_5_5_5_1,GL_UNSIGNED_SHORT_1_5_5_5_REV,GL_UNSIGNED_INT_8_8_8_8,GL_UNSIGNED_INT_8_8_8_8_REV,GL_UNSIGNED_INT_10_10_10_2, andGL_UNSIGNED_INT_2_10_10_10_REV. π§¬dataβ a pointer to the image data in memory. π«Ά
πΈ DESCRIPTION πΈ
Texturing maps a portion of a specified texture image onto each graphical primitive for which texturing is enabled. To enable and disable three-dimensional texturing, call glEnable() and glDisable with argument GL_TEXTURE_3D. π
To define texture images, call glTexImage3D. The arguments describe the parameters of the texture image, such as height, width, depth, width of the border, level-of-detail number (see glTexParameter()), and number of color components provided. The last three arguments describe how the image is represented in memory. π§
If target is GL_PROXY_TEXTURE_3D, no data is read from data, but all of the texture image state is recalculated, checked for consistency, and checked against the implementation's capabilities. If the implementation cannot handle a texture of the requested texture size, it sets all of the image state to 0, but does not generate an error (see glGetError()). To query for an entire mipmap array, use an image array level greater than or equal to 1. π
If target is GL_TEXTURE_3D, data is read from data as a sequence of signed or unsigned bytes, shorts, or longs, or single-precision floating-point values, depending on type. These values are grouped into sets of one, two, three, or four values, depending on format, to form elements. Each data byte is treated as eight 1-bit elements, with bit ordering determined by GL_UNPACK_LSB_FIRST (see glPixelStore()). π₯
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. π«Ά
The first element corresponds to the lower left corner of the texture image. Subsequent elements progress left-to-right through the remaining texels in the lowest row of the texture image, and then in successively higher rows of the texture image. The final element corresponds to the upper right corner of the texture image. π§
format determines the composition of each element in data. It can assume one of these symbolic values:
GL_REDβ each element is a single red component. The GL converts it to floating point and assembles it into an RGBA element by attaching0for green and blue, and1for alpha. Each component is clamped to the range[0,1]. β€οΈGL_RGβ each element is a red and green pair. The GL converts each to floating point and assembles it into an RGBA element by attaching0for blue, and1for alpha. Each component is clamped to the range[0,1]. πGL_RGB,GL_BGRβ each element is an RGB triple. The GL converts it to floating point and assembles it into an RGBA element by attaching1for alpha. Each component is clamped to the range[0,1]. πGL_RGBA,GL_BGRAβ each element contains all four components. Each component is clamped to the range[0,1]. π
If an application wants to store the texture at a certain resolution or in a certain format, it can request the resolution and format with internalformat. The GL will choose an internal representation that closely approximates that requested by internalformat, but it may not match exactly. (The representations specified by GL_RED, GL_RG, GL_RGB, and GL_RGBA must match exactly.) π
internalformat may be one of the base internal formats shown in Table 1, below π
π Table 1. Base Internal Formats π
- Base Internal Format:
GL_DEPTH_COMPONENTβ RGBA, Depth and Stencil Values: Depth β Internal Components:D - Base Internal Format:
GL_DEPTH_STENCILβ RGBA, Depth and Stencil Values: Depth, Stencil β Internal Components:D, S - Base Internal Format:
GL_REDβ RGBA, Depth and Stencil Values: Red β Internal Components:R - Base Internal Format:
GL_RGβ RGBA, Depth and Stencil Values: Red, Green β Internal Components:R, G - Base Internal Format:
GL_RGBβ RGBA, Depth and Stencil Values: Red, Green, Blue β Internal Components:R, G, B - Base Internal Format:
GL_RGBAβ RGBA, Depth and Stencil Values: Red, Green, Blue, Alpha β Internal Components:R, G, B, A
internalformat may also be one of the sized internal formats shown in Table 2, below πΈ
So this is the big one β Table 2. Sized Internal Formats π and bestie, it's a whole buffet. The columns are: Sized Internal Format, Base Internal Format, Red Bits, Green Bits, Blue Bits, Alpha Bits, and Shared Bits. Heads up: the Shared Bits column is sitting there cute and empty for literally every row in this stretch β nobody's using it yet π
. Also, the s prefix = signed, ui = unsigned integer, f = float. Iykyk.
GL_R8β baseGL_RED, red bits8GL_R8_SNORMβ baseGL_RED, red bitss8GL_R16β baseGL_RED, red bits16GL_R16_SNORMβ baseGL_RED, red bitss16GL_RG8β baseGL_RG, red bits8, green bits8GL_RG8_SNORMβ baseGL_RG, red bitss8, green bitss8GL_RG16β baseGL_RG, red bits16, green bits16GL_RG16_SNORMβ baseGL_RG, red bitss16, green bitss16GL_R3_G3_B2β baseGL_RGB, red bits3, green bits3, blue bits2GL_RGB4β baseGL_RGB, red bits4, green bits4, blue bits4GL_RGB5β baseGL_RGB, red bits5, green bits5, blue bits5GL_RGB8β baseGL_RGB, red bits8, green bits8, blue bits8GL_RGB8_SNORMβ baseGL_RGB, red bitss8, green bitss8, blue bitss8GL_RGB10β baseGL_RGB, red bits10, green bits10, blue bits10GL_RGB12β baseGL_RGB, red bits12, green bits12, blue bits12GL_RGB16_SNORMβ baseGL_RGB, red bits16, green bits16, blue bits16GL_RGBA2β baseGL_RGB, red bits2, green bits2, blue bits2, alpha bits2GL_RGBA4β baseGL_RGB, red bits4, green bits4, blue bits4, alpha bits4GL_RGB5_A1β baseGL_RGBA, red bits5, green bits5, blue bits5, alpha bits1GL_RGBA8β baseGL_RGBA, red bits8, green bits8, blue bits8, alpha bits8GL_RGBA8_SNORMβ baseGL_RGBA, red bitss8, green bitss8, blue bitss8, alpha bitss8GL_RGB10_A2β baseGL_RGBA, red bits10, green bits10, blue bits10, alpha bits2GL_RGB10_A2UIβ baseGL_RGBA, red bitsui10, green bitsui10, blue bitsui10, alpha bitsui2GL_RGBA12β baseGL_RGBA, red bits12, green bits12, blue bits12, alpha bits12GL_RGBA16β baseGL_RGBA, red bits16, green bits16, blue bits16, alpha bits16GL_SRGB8β baseGL_RGB, red bits8, green bits8, blue bits8GL_SRGB8_ALPHA8β baseGL_RGBA, red bits8, green bits8, blue bits8, alpha bits8GL_R16Fβ baseGL_RED, red bitsf16
β¦and the sized-format rollout continues, bestie π same deal as above: internal format on the left, and then the channel layout it's giving.
GL_RG16Fβ baseGL_RGΒ· redf16Β· greenf16GL_RGB16Fβ baseGL_RGBΒ· redf16Β· greenf16Β· bluef16GL_RGBA16Fβ baseGL_RGBAΒ· redf16Β· greenf16Β· bluef16Β· alphaf16GL_R32Fβ baseGL_REDΒ· redf32β one channel, zero drama πΈGL_RG32Fβ baseGL_RGΒ· redf32Β· greenf32GL_RGB32Fβ baseGL_RGBΒ· redf32Β· greenf32Β· bluef32GL_RGBA32Fβ baseGL_RGBAΒ· redf32Β· greenf32Β· bluef32Β· alphaf32β the full float squad, iconic πGL_R11F_G11F_B10Fβ baseGL_RGBΒ· redf11Β· greenf11Β· bluef10β yes, the blue one is a whole bit smaller, it's fine, it's fine πGL_RGB9_E5β baseGL_RGBΒ· red9Β· green9Β· blue9Β· shared5GL_R8Iβ baseGL_REDΒ· redi8GL_R8UIβ baseGL_REDΒ· redui8GL_R16Iβ baseGL_REDΒ· redi16GL_R16UIβ baseGL_REDΒ· redui16GL_R32Iβ baseGL_REDΒ· redi32GL_R32UIβ baseGL_REDΒ· redui32GL_RG8Iβ baseGL_RGΒ· redi8Β· greeni8GL_RG8UIβ baseGL_RGΒ· redui8Β· greenui8GL_RG16Iβ baseGL_RGΒ· redi16Β· greeni16GL_RG16UIβ baseGL_RGΒ· redui16Β· greenui16GL_RG32Iβ baseGL_RGΒ· redi32Β· greeni32GL_RG32UIβ baseGL_RGΒ· redui32Β· greenui32GL_RGB8Iβ baseGL_RGBΒ· redi8Β· greeni8Β· bluei8GL_RGB8UIβ baseGL_RGBΒ· redui8Β· greenui8Β· blueui8GL_RGB16Iβ baseGL_RGBΒ· redi16Β· greeni16Β· bluei16GL_RGB16UIβ baseGL_RGBΒ· redui16Β· greenui16Β· blueui16GL_RGB32Iβ baseGL_RGBΒ· redi32Β· greeni32Β· bluei32GL_RGB32UIβ baseGL_RGBΒ· redui32Β· greenui32Β· blueui32GL_RGBA8Iβ baseGL_RGBAΒ· redi8Β· greeni8Β· bluei8Β· alphai8GL_RGBA8UIβ baseGL_RGBAΒ· redui8Β· greenui8Β· blueui8Β· alphaui8GL_RGBA16Iβ baseGL_RGBAΒ· redi16Β· greeni16Β· bluei16Β· alphai16GL_RGBA16UIβ baseGL_RGBAΒ· redui16Β· greenui16Β· blueui16Β· alphaui16
okay and it literally keeps going, keep scrolling bestie ππ¦
GL_RGBA32Iβ base internal formatGL_RGBA, and the four components arei32,i32,i32,i32β¨GL_RGBA32UIβ base internal formatGL_RGBA, componentsui32,ui32,ui32,ui32π«Ά
And finally, bestie, internalformat can also be one of the generic or compressed texture formats β those are all hanging out in Table 3 down below π
π Table 3. Compressed Internal Formats
GL_COMPRESSED_REDβ base internal formatGL_RED, type GenericGL_COMPRESSED_RGβ base internal formatGL_RG, type GenericGL_COMPRESSED_RGBβ base internal formatGL_RGB, type GenericGL_COMPRESSED_RGBAβ base internal formatGL_RGBA, type GenericGL_COMPRESSED_SRGBβ base internal formatGL_RGB, type GenericGL_COMPRESSED_SRGB_ALPHAβ base internal formatGL_RGBA, type GenericGL_COMPRESSED_RED_RGTC1β base internal formatGL_RED, type SpecificGL_COMPRESSED_SIGNED_RED_RGTC1β base internal formatGL_RED, type SpecificGL_COMPRESSED_RG_RGTC2β base internal formatGL_RG, type SpecificGL_COMPRESSED_SIGNED_RG_RGTC2β base internal formatGL_RG, type SpecificGL_COMPRESSED_RGBA_BPTC_UNORMβ base internal formatGL_RGBA, type SpecificGL_COMPRESSED_SRGB_ALPHA_BPTC_UNORMβ base internal formatGL_RGBA, type SpecificGL_COMPRESSED_RGB_BPTC_SIGNED_FLOATβ base internal formatGL_RGB, type SpecificGL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOATβ base internal formatGL_RGB, type Specific
So here's the tea on the generic ones β β if internalformat is one of the generic compressed formats, like GL_COMPRESSED_RED, GL_COMPRESSED_RG, GL_COMPRESSED_RGB, or GL_COMPRESSED_RGBA, then the GL will swap the internal format out for the symbolic constant of a specific internal format and compress the texture before it stores it. Iconic, honestly π
But β and this is the plot twist β if there's no corresponding internal format available, or the GL just can't compress that image for literally any reason, then the internal format gets replaced with a corresponding base internal format instead. No compression for you π₯²
π¦ the sRGB situation
If internalformat is GL_SRGB, GL_SRGB8, GL_SRGB_ALPHA, or GL_SRGB8_ALPHA8, the texture gets treated as if the red, green, blue, or luminance components are encoded in the sRGB color space. Any alpha component is left completely unchanged, untouched, unbothered π
The conversion from an sRGB encoded component c s to a linear component c l is:
c_l = { c_s / 12.92 if c_s β€ 0.04045
{ ((c_s + 0.055) / 1.055) ^ 2.4 if c_s > 0.04045
And just so we're clear, assume c s is the sRGB component in the range [0,1] π
π§ vibe check: the proxy target
Use the GL_PROXY_TEXTURE_3D target to try out a resolution and format before committing β like a fitting room but for textures, lowkey genius π The implementation will update and recompute its best match for the requested storage resolution and format. To then query this state, call glGetTexLevelParameter(). And if the texture cannot be accommodated? Texture state is set to 0. Brutal but fair π
πΈ how many components, exactly?
Okay so a one-component texture image uses only the red component of the RGBA color extracted from data. A two-component image uses the R and A values. A three-component image uses the R, G, and B values. And a four-component image uses all of the RGBA components. All four. The whole squad π«Ά
β¨ NOTES β¨
- The
glPixelStore()mode affects texture images. Yes, it really does. Keep an eye on it π datamay be a null pointer. In this case, texture memory is allocated to accommodate a texture of width width, height height, and depth depth. You can then download subtextures to initialize this texture memory. The image is undefined if the user tries to apply an uninitialized portion of the texture image to a primitive β so like, don't do that πglTexImage3Dspecifies the three-dimensional texture for the current texture unit, specified withglActiveTexture(). Main character energy β¨GL_STENCIL_INDEXmay be used forformatonly if the GL version is4.4or higher. Version gate, bestie π§
π ERRORS π
Strap in, this is the long one. Here's every way this call can yell at you:
GL_INVALID_ENUMis generated iftargetis notGL_TEXTURE_3DorGL_PROXY_TEXTURE_3D.GL_INVALID_ENUMis generated ifformatis not an accepted format constant. Format constants other thanGL_STENCIL_INDEXandGL_DEPTH_COMPONENTare accepted.GL_INVALID_ENUMis generated iftypeis not a type constant.GL_INVALID_VALUEis generated iflevelis less than0.GL_INVALID_VALUEmay be generated iflevelis greater thanlog2of max, where max is the returned value ofGL_MAX_TEXTURE_SIZE.GL_INVALID_VALUEis generated ifinternalformatis not one of the accepted resolution and format symbolic constants.GL_INVALID_VALUEis generated ifwidth,height, ordepthis less than0or greater thanGL_MAX_TEXTURE_SIZE.GL_INVALID_VALUEis generated ifborderis not0.GL_INVALID_OPERATIONis generated iftypeis one ofGL_UNSIGNED_BYTE_3_3_2,GL_UNSIGNED_BYTE_2_3_3_REV,GL_UNSIGNED_SHORT_5_6_5, orGL_UNSIGNED_SHORT_5_6_5_REVandformatis notGL_RGB.GL_INVALID_OPERATIONis generated iftypeis one ofGL_UNSIGNED_SHORT_4_4_4_4,GL_UNSIGNED_SHORT_4_4_4_4_REV,GL_UNSIGNED_SHORT_5_5_5_1,GL_UNSIGNED_SHORT_1_5_5_5_REV,GL_UNSIGNED_INT_8_8_8_8,GL_UNSIGNED_INT_8_8_8_8_REV,GL_UNSIGNED_INT_10_10_10_2, orGL_UNSIGNED_INT_2_10_10_10_REVandformatis neitherGL_RGBAnorGL_BGRA.GL_INVALID_OPERATIONis generated ifformatorinternalformatisGL_DEPTH_COMPONENT,GL_DEPTH_COMPONENT16,GL_DEPTH_COMPONENT24, orGL_DEPTH_COMPONENT32.GL_INVALID_OPERATIONis generated if a non-zero buffer object name is bound to theGL_PIXEL_UNPACK_BUFFERtarget 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_UNPACK_BUFFERtarget and the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size.GL_INVALID_OPERATIONis generated if a non-zero buffer object name is bound to theGL_PIXEL_UNPACK_BUFFERtarget anddatais not evenly divisible into the number of bytes needed to store in memory a datum indicated bytype.
fr fr, those last three are always about the unpack buffer. It's giving "it's always the buffer" π
π₯ ASSOCIATED GETS π₯
glGetTexImage()glGet()with argumentGL_PIXEL_UNPACK_BUFFER_BINDING
These are your receipts, bestie π
β¨ VERSION SUPPORT β¨
okay bestie, this is the glow-up chart β which OpenGL versions actually show up for you π The columns are OpenGL Version, the rows are Function / Feature Name, and here's the tea:
glTexImage3Dβ slayed in literally every single one, no skips, no gaps:- OpenGL 2.0 β β
- OpenGL 2.1 β β
- OpenGL 3.0 β β
- OpenGL 3.1 β β
- OpenGL 3.2 β β
- OpenGL 3.3 β β
- OpenGL 4.0 β β
- OpenGL 4.1 β β
- OpenGL 4.2 β β
- OpenGL 4.3 β β
- OpenGL 4.4 β β
- OpenGL 4.5 β β
GL_HALF_FLOATβ she was not invited to the early parties, poor thing π:- OpenGL 2.0 β
- - OpenGL 2.1 β
- - OpenGL 3.0 β β
- OpenGL 3.1 β β
- OpenGL 3.2 β β
- OpenGL 3.3 β β
- OpenGL 4.0 β β
- OpenGL 4.1 β β
- OpenGL 4.2 β β
- OpenGL 4.3 β β
- OpenGL 4.4 β β
- OpenGL 4.5 β β
- OpenGL 2.0 β
so like, glTexImage3D ate from 2.0 onward and never looked back, but GL_HALF_FLOAT was a late bloomer who showed up in 3.0 and stayed iconic πΈ
π SEE ALSO
your reading list, bestie β go click around, it's giving "study group" energy πβ¨
glActiveTexture()glCompressedTexImage1D()glCompressedTexImage2D()glCompressedTexImage3D()glCompressedTexSubImage1D()glCompressedTexSubImage2D()glCompressedTexSubImage3D()glCopyTexImage1D()glCopyTexImage2D()glCopyTexSubImage1D()glCopyTexSubImage2D()glCopyTexSubImage3D()glGetCompressedTexImage()glPixelStore()glTexImage1D()glTexImage2D()glTexSubImage1D()glTexSubImage2D()glTexSubImage3D()glTexParameter()
π COPYRIGHT
Copyright Β© 1991-2006 Silicon Graphics, Inc. Copyright Β© 2011-2014 Khronos Group. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.
π COPYRIGHT (yes, again, she's thorough π )
Copyright Β© 2011-2014 Khronos Group
and that's a wrap on this whole page, bestie π you made it to the end β so proud of you fr fr π«Ά This lil masterpiece was served up from [FIXME: source], dated 08/09/2021, and it lives at GLTEXIMAGE3D(3G) β go forth and texture in 3D, you gorgeous main character πβ¨
π¦ 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