GLTEXIMAGE2D(3G)

๐ŸŒธ NAME ๐ŸŒธ

okay bestie, welcome to GLTEXIMAGE2D(3G) โ€” the manual page for glTexImage2D, and its entire main character job is: glTexImage2D - specify a two-dimensional texture image. thatโ€™s it, thatโ€™s the assignment, and it ate. ๐Ÿ’…โœจ

๐Ÿ’… C SPECIFICATION ๐Ÿ’…

void glTexImage2D(GLenum target, GLint level, GLint internalformat,
                  GLsizei width, GLsizei height, GLint border,
                  GLenum format, GLenum type, const GLvoid * data);

โœจ PARAMETERS โœจ

  • target โ€” says which texture target youโ€™re aiming at. Must be GL_TEXTURE_2D, GL_PROXY_TEXTURE_2D, GL_TEXTURE_1D_ARRAY, GL_PROXY_TEXTURE_1D_ARRAY, GL_TEXTURE_RECTANGLE, GL_PROXY_TEXTURE_RECTANGLE, 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. no mystery targets, bestie.
  • level โ€” the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image. If target is GL_TEXTURE_RECTANGLE or GL_PROXY_TEXTURE_RECTANGLE, level must be 0. rectangles stay at level zero, periodt.
  • internalformat โ€” says how many color components are 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. we love a format with range.
  • width โ€” the width of the texture image. All implementations support texture images that are at least 1024 texels wide. yes, 1024 is the lowkey minimum flex.
  • height โ€” the height of the texture image, or the number of layers in a texture array when target is GL_TEXTURE_1D_ARRAY or GL_PROXY_TEXTURE_1D_ARRAY. All implementations support 2D texture images that are at least 1024 texels high, and texture arrays that are at least 256 layers deep. stack those layers, icon.
  • border โ€” this value must be 0. literally zero. not a vibe option.
  • 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, and GL_UNSIGNED_INT_2_10_10_10_REV.
  • data โ€” a pointer to the image data in memory. the actual pixels live here, bestie.

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

Texturing is literally how shaders get to read elements of an image array. ๐Ÿ‘‘

To define texture images, you call glTexImage2D. The arguments describe the texture imageโ€™s parameters โ€” stuff like height, width, 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. iykyk, memory layout matters.

If target is GL_PROXY_TEXTURE_2D, GL_PROXY_TEXTURE_1D_ARRAY, GL_PROXY_TEXTURE_CUBE_MAP, or GL_PROXY_TEXTURE_RECTANGLE, 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. proxy mode is giving โ€œvibe check only, no pixels read.โ€

If target is GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, or one of the GL_TEXTURE_CUBE_MAP targets, 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()). bit order said pay attention to me.

If target is GL_TEXTURE_1D_ARRAY, data is interpreted as an array of one-dimensional images.

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. buffer-bound era, truly.

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. we start bottom-left and climb, no cap.

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 attaching 0 for green and blue, and 1 for alpha. Each component is clamped to the range [0,1].
  • GL_RG โ€” each element is a red/green double. The GL converts it to floating point and assembles it into an RGBA element by attaching 0 for blue, and 1 for 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 attaching 1 for 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]. full RGBA main character energy.
  • GL_DEPTH_COMPONENT โ€” each element is a single depth value. The GL converts it to floating point and clamps to the range [0,1].
  • GL_DEPTH_STENCIL โ€” each element is a pair of depth and stencil values. The depth component of the pair is interpreted as in GL_DEPTH_COMPONENT. The stencil component is interpreted based on the specified depth + stencil internal format.

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 the one 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.) close enough is fine for most, but those four said exact or nothing.

internalformat may be one of the base internal formats shown in Table 1, below.


๐Ÿ“ Table 1. Base Internal Formats ๐Ÿ“

the columns are Base Internal Format, RGBA, Depth and Stencil Values, and Internal Components โ€” hereโ€™s the whole lineup:

  • GL_DEPTH_COMPONENT โ€” RGBA, Depth and Stencil Values: Depth; Internal Components: D
  • GL_DEPTH_STENCIL โ€” RGBA, Depth and Stencil Values: Depth, Stencil; Internal Components: D, S
  • GL_RED โ€” RGBA, Depth and Stencil Values: Red; Internal Components: R
  • GL_RG โ€” RGBA, Depth and Stencil Values: Red, Green; Internal Components: R, G
  • GL_RGB โ€” RGBA, Depth and Stencil Values: Red, Green, Blue; Internal Components: R, G, B
  • 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.

Table 2. Sized Internal Formats

Okay bestie, column vibe check โœจ: Sized Internal Format, Base Internal Format, Red Bits, Green Bits, Blue Bits, Alpha Bits, Shared Bits. The Shared Bits column is blank for every single row here, so just picture a sparkly lil empty column and don't come for me ๐Ÿ’…. Blank means the cell is empty in the original, not that I forgot it.

  • GL_R8 โ€” base GL_RED; red 8; green blank; blue blank; alpha blank; shared blank.
  • GL_R8_SNORM โ€” base GL_RED; red s8; green blank; blue blank; alpha blank; shared blank.
  • GL_R16 โ€” base GL_RED; red 16; green blank; blue blank; alpha blank; shared blank.
  • GL_R16_SNORM โ€” base GL_RED; red s16; green blank; blue blank; alpha blank; shared blank.
  • GL_RG8 โ€” base GL_RG; red 8; green 8; blue blank; alpha blank; shared blank.
  • GL_RG8_SNORM โ€” base GL_RG; red s8; green s8; blue blank; alpha blank; shared blank.
  • GL_RG16 โ€” base GL_RG; red 16; green 16; blue blank; alpha blank; shared blank.
  • GL_RG16_SNORM โ€” base GL_RG; red s16; green s16; blue blank; alpha blank; shared blank.
  • GL_R3_G3_B2 โ€” base GL_RGB; red 3; green 3; blue 2; alpha blank; shared blank.
  • GL_RGB4 โ€” base GL_RGB; red 4; green 4; blue 4; alpha blank; shared blank.
  • GL_RGB5 โ€” base GL_RGB; red 5; green 5; blue 5; alpha blank; shared blank.
  • GL_RGB8 โ€” base GL_RGB; red 8; green 8; blue 8; alpha blank; shared blank.
  • GL_RGB8_SNORM โ€” base GL_RGB; red s8; green s8; blue s8; alpha blank; shared blank.
  • GL_RGB10 โ€” base GL_RGB; red 10; green 10; blue 10; alpha blank; shared blank.
  • GL_RGB12 โ€” base GL_RGB; red 12; green 12; blue 12; alpha blank; shared blank.
  • GL_RGB16_SNORM โ€” base GL_RGB; red 16; green 16; blue 16; alpha blank; shared blank.
  • GL_RGBA2 โ€” base GL_RGB; red 2; green 2; blue 2; alpha 2; shared blank. Yes, the base says GL_RGB โ€” I'm copying it exactly, no edits ๐Ÿ‘€.
  • GL_RGBA4 โ€” base GL_RGB; red 4; green 4; blue 4; alpha 4; shared blank.
  • GL_RGB5_A1 โ€” base GL_RGBA; red 5; green 5; blue 5; alpha 1; shared blank.
  • GL_RGBA8 โ€” base GL_RGBA; red 8; green 8; blue 8; alpha 8; shared blank.
  • GL_RGBA8_SNORM โ€” base GL_RGBA; red s8; green s8; blue s8; alpha s8; shared blank.
  • GL_RGB10_A2 โ€” base GL_RGBA; red 10; green 10; blue 10; alpha 2; shared blank.
  • GL_RGB10_A2UI โ€” base GL_RGBA; red ui10; green ui10; blue ui10; alpha ui2; shared blank.
  • GL_RGBA12 โ€” base GL_RGBA; red 12; green 12; blue 12; alpha 12; shared blank.
  • GL_RGBA16 โ€” base GL_RGBA; red 16; green 16; blue 16; alpha 16; shared blank.
  • GL_SRGB8 โ€” base GL_RGB; red 8; green 8; blue 8; alpha blank; shared blank.
  • GL_SRGB8_ALPHA8 โ€” base GL_RGBA; red 8; green 8; blue 8; alpha 8; shared blank.
  • GL_R16F โ€” base GL_RED; red f16; green blank; blue blank; alpha blank; shared blank.

...and we're still going, bestie ๐Ÿ˜ญ the table is long but we're so close. Quick legend so you don't get lost: each row is internal format โ†’ the format it pairs with โ†’ the component types for R, G, B, A in that order โ†’ and the last slot is the shared exponent bits ๐ŸŒˆ

  • GL_RG16F โ€” format GL_RG, components f16 (R), f16 (G) โœจ
  • GL_RGB16F โ€” format GL_RGB, components f16 (R), f16 (G), f16 (B) ๐Ÿ’–
  • GL_RGBA16F โ€” format GL_RGBA, components f16 (R), f16 (G), f16 (B), f16 (A) ๐ŸŽ€
  • GL_R32F โ€” format GL_RED, component f32 (R) ๐Ÿฆ‹
  • GL_RG32F โ€” format GL_RG, components f32 (R), f32 (G)
  • GL_RGB32F โ€” format GL_RGB, components f32 (R), f32 (G), f32 (B)
  • GL_RGBA32F โ€” format GL_RGBA, components f32 (R), f32 (G), f32 (B), f32 (A) ๐Ÿ”ฅ
  • GL_R11F_G11F_B10F โ€” format GL_RGB, components f11 (R), f11 (G), f10 (B) ๐ŸŒธ
  • GL_RGB9_E5 โ€” format GL_RGB, components 9 (R), 9 (G), 9 (B), and 5 shared ๐Ÿ‘‘
  • GL_R8I โ€” format GL_RED, component i8 (R)
  • GL_R8UI โ€” format GL_RED, component ui8 (R)
  • GL_R16I โ€” format GL_RED, component i16 (R)
  • GL_R16UI โ€” format GL_RED, component ui16 (R)
  • GL_R32I โ€” format GL_RED, component i32 (R)
  • GL_R32UI โ€” format GL_RED, component ui32 (R)
  • GL_RG8I โ€” format GL_RG, components i8 (R), i8 (G)
  • GL_RG8UI โ€” format GL_RG, components ui8 (R), ui8 (G)
  • GL_RG16I โ€” format GL_RG, components i16 (R), i16 (G)
  • GL_RG16UI โ€” format GL_RG, components ui16 (R), ui16 (G)
  • GL_RG32I โ€” format GL_RG, components i32 (R), i32 (G)
  • GL_RG32UI โ€” format GL_RG, components ui32 (R), ui32 (G)
  • GL_RGB8I โ€” format GL_RGB, components i8 (R), i8 (G), i8 (B)
  • GL_RGB8UI โ€” format GL_RGB, components ui8 (R), ui8 (G), ui8 (B)
  • GL_RGB16I โ€” format GL_RGB, components i16 (R), i16 (G), i16 (B)
  • GL_RGB16UI โ€” format GL_RGB, components ui16 (R), ui16 (G), ui16 (B)
  • GL_RGB32I โ€” format GL_RGB, components i32 (R), i32 (G), i32 (B)
  • GL_RGB32UI โ€” format GL_RGB, components ui32 (R), ui32 (G), ui32 (B)
  • GL_RGBA8I โ€” format GL_RGBA, components i8 (R), i8 (G), i8 (B), i8 (A)
  • GL_RGBA8UI โ€” format GL_RGBA, components ui8 (R), ui8 (G), ui8 (B), ui8 (A)
  • GL_RGBA16I โ€” format GL_RGBA, components i16 (R), i16 (G), i16 (B), i16 (A)
  • GL_RGBA16UI โ€” format GL_RGBA, components ui16 (R), ui16 (G), ui16 (B), ui16 (A) ๐Ÿ’œ

Lowkey this list is the moment, ngl โ€” every internal format, its matching format, and exactly what each channel holds, all laid out so you can just vibe-check your texture setup against it ๐Ÿซถ

โ€ฆand those last integer rows from the internal-format table finish out like this ๐Ÿซถ

  • GL_RGBA32I โ€” base internal format GL_RGBA; R = i32, G = i32, B = i32, A = i32; last column blank.
  • GL_RGBA32UI โ€” base internal format GL_RGBA; R = ui32, G = ui32, B = ui32, A = ui32; last column blank.

okay and internalformat can also be one of the generic or compressed texture formats, bestie โ€” Table 3 below has the whole lineup ๐Ÿ‘‘

Table 3. Compressed Internal Formats

The columns are Compressed Internal Format, Base Internal Format, and Type. Every row, no skipping:

  • GL_COMPRESSED_RED โ†’ base internal format GL_RED โ†’ Generic
  • GL_COMPRESSED_RG โ†’ base internal format GL_RG โ†’ Generic
  • GL_COMPRESSED_RGB โ†’ base internal format GL_RGB โ†’ Generic
  • GL_COMPRESSED_RGBA โ†’ base internal format GL_RGBA โ†’ Generic
  • GL_COMPRESSED_SRGB โ†’ base internal format GL_RGB โ†’ Generic
  • GL_COMPRESSED_SRGB_ALPHA โ†’ base internal format GL_RGBA โ†’ Generic
  • GL_COMPRESSED_RED_RGTC1 โ†’ base internal format GL_RED โ†’ Specific
  • GL_COMPRESSED_SIGNED_RED_RGTC1 โ†’ base internal format GL_RED โ†’ Specific
  • GL_COMPRESSED_RG_RGTC2 โ†’ base internal format GL_RG โ†’ Specific
  • GL_COMPRESSED_SIGNED_RG_RGTC2 โ†’ base internal format GL_RG โ†’ Specific
  • GL_COMPRESSED_RGBA_BPTC_UNORM โ†’ base internal format GL_RGBA โ†’ Specific
  • GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM โ†’ base internal format GL_RGBA โ†’ Specific
  • GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT โ†’ base internal format GL_RGB โ†’ Specific
  • GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT โ†’ base internal format GL_RGB โ†’ Specific

If the internalformat parameter is one of the generic compressed formats โ€” GL_COMPRESSED_RED, GL_COMPRESSED_RG, GL_COMPRESSED_RGB, or GL_COMPRESSED_RGBA โ€” the GL will replace the internal format with the symbolic constant for a specific internal format and compress the texture before storage. If no corresponding internal format is available, or the GL can not compress that image for any reason, the internal format is instead replaced with a corresponding base internal format. ๐Ÿ’…

If the internalformat parameter is GL_SRGB, GL_SRGB8, GL_SRGB_ALPHA, or GL_SRGB8_ALPHA8, the texture is treated as if the red, green, or blue components are encoded in the sRGB color space. Any alpha component is left unchanged. The conversion from the sRGB encoded component c_s to a linear component c_l is:

c_l = c_s / 12.92                    if c_s โ‰ค 0.04045
c_l = ((c_s + 0.055) / 1.055)^2.4    if c_s > 0.04045

Assume c_s is the sRGB component in the range [0,1].

Use the GL_PROXY_TEXTURE_2D, GL_PROXY_TEXTURE_1D_ARRAY, GL_PROXY_TEXTURE_RECTANGLE, or GL_PROXY_TEXTURE_CUBE_MAP target to try out a resolution and format. The implementation will update and recompute its best match for the requested storage resolution and format. To then query this state, call glGetTexLevelParameter(). If the texture cannot be accommodated, texture state is set to 0. ๐Ÿ˜ญ

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 G values. A three-component image uses the R, G, and B values. A four-component image uses all of the RGBA components. ๐ŸŒˆ

Image-based shadowing can be enabled by comparing texture r coordinates to depth texture values to generate a boolean result. See glTexParameter() for details on texture comparison.


โœจ NOTES โœจ

The glPixelStore() mode affects texture images.

data may be a null pointer. In this case, texture memory is allocated to accommodate a texture of width width and height height. 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. ๐Ÿซถ

glTexImage2D specifies the two-dimensional texture for the current texture unit, specified with glActiveTexture().

GL_STENCIL_INDEX may be used for format only if the GL version is 4.4 or higher. ๐Ÿ‘‘

๐Ÿ’€ ERRORS ๐Ÿ’€

okay bestie, this is the part where OpenGL yells at you. listen up, because these are the receipts it throws back ๐Ÿงพโœจ

  • GL_INVALID_ENUM โ€” bestie you gave it a target that is literally not one of these: GL_TEXTURE_2D, GL_TEXTURE_1D_ARRAY, GL_TEXTURE_RECTANGLE, GL_PROXY_TEXTURE_2D, GL_PROXY_TEXTURE_1D_ARRAY, GL_PROXY_TEXTURE_RECTANGLE, GL_PROXY_TEXTURE_CUBE_MAP, 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, or GL_TEXTURE_CUBE_MAP_NEGATIVE_Z. like, pick one that's on the list babe ๐Ÿ˜ญ
  • GL_INVALID_ENUM โ€” also fires if target is one of the six cube map 2D image targets and your width and height are not equal. cubes gotta be square, that's the whole vibe ๐ŸŽฒ
  • GL_INVALID_ENUM โ€” if type is not a type constant. any type constant. just not that one ๐Ÿ™ˆ
  • GL_INVALID_VALUE โ€” if width is less than 0 or greater than GL_MAX_TEXTURE_SIZE.
  • GL_INVALID_VALUE โ€” if target is not GL_TEXTURE_1D_ARRAY or GL_PROXY_TEXTURE_1D_ARRAY and height is less than 0 or greater than GL_MAX_TEXTURE_SIZE.
  • GL_INVALID_VALUE โ€” if target is GL_TEXTURE_1D_ARRAY or GL_PROXY_TEXTURE_1D_ARRAY and height is less than 0 or greater than GL_MAX_ARRAY_TEXTURE_LAYERS. different ceiling for array girlies, iykyk ๐Ÿ’…
  • GL_INVALID_VALUE โ€” if level is less than 0. negative mip levels are not a thing, periodt.
  • 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. (yes, may. it's giving mysterious โœจ)
  • GL_INVALID_VALUE โ€” if internalformat is not one of the accepted resolution and format symbolic constants.
  • GL_INVALID_VALUE โ€” if width or height is less than 0 or greater than GL_MAX_TEXTURE_SIZE. (yeah she's on here twice, she's thorough ๐Ÿ’€)
  • GL_INVALID_VALUE โ€” if border is not 0. zero. only zero. no border era, we're done with it ๐Ÿšซ
  • GL_INVALID_OPERATION โ€” if type is one of 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, or GL_UNSIGNED_INT_10F_11F_11F_REV, and format is not GL_RGB. these ones are RGB-only, no exceptions bestie ๐ŸŒˆ
  • GL_INVALID_OPERATION โ€” if type is one of 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, GL_UNSIGNED_INT_2_10_10_10_REV, or GL_UNSIGNED_INT_5_9_9_9_REV, and format is neither GL_RGBA nor GL_BGRA. these pack alpha, so they need their alpha-coded format. main character requirements ๐ŸŽ€
  • GL_INVALID_OPERATION โ€” if target is not GL_TEXTURE_2D, GL_PROXY_TEXTURE_2D, GL_TEXTURE_RECTANGLE, or GL_PROXY_TEXTURE_RECTANGLE, and internalformat is GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, or GL_DEPTH_COMPONENT32F. depth formats are 2D/rectangle girlies only ๐Ÿ’œ
  • GL_INVALID_OPERATION โ€” if format is GL_DEPTH_COMPONENT and internalformat is not GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, or GL_DEPTH_COMPONENT32F. depth in, depth out, matching set only โœจ
  • GL_INVALID_OPERATION โ€” if internalformat is GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, or GL_DEPTH_COMPONENT32F, and format is not GL_DEPTH_COMPONENT. yeah, she's the mirror of the one above. both directions, no cap ๐Ÿชž
  • GL_INVALID_OPERATION โ€” 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. bestie you can't read from something that's mid-edit ๐Ÿ˜ค
  • GL_INVALID_OPERATION โ€” 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. stay in your lane, memory-wise ๐Ÿšง
  • GL_INVALID_OPERATION โ€” if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and data is not evenly divisible into the number of bytes needed to store in memory a datum indicated by type. the math has to math, fr fr ๐Ÿงฎ
  • GL_INVALID_VALUE โ€” if target is GL_TEXTURE_RECTANGLE or GL_PROXY_TEXTURE_RECTANGLE and level is not 0. rectangles have exactly one level and they're at peace with it ๐ŸŒธ

๐Ÿ” ASSOCIATED GETS ๐Ÿ”

the reverse-uno cards you can peek with, bestie:

  • glGetTexImage()
  • glGet() with argument GL_PIXEL_UNPACK_BUFFER_BINDING

๐Ÿ“‹ VERSION SUPPORT ๐Ÿ“‹

the original ships this as a big grid, and since we're out here in terminal-land with no tables, here's the same tea in list form ๐Ÿตโœจ

glTexImage2D

  • 2.0 โ€” โœ”
  • 2.1 โ€” โœ”
  • 3.0 โ€” โœ”
  • 3.1 โ€” โœ”
  • 3.2 โ€” โœ”
  • 3.3 โ€” โœ”
  • 4.0 โ€” โœ”
  • 4.1 โ€” โœ”
  • 4.2 โ€” โœ”
  • 4.3 โ€” โœ”
  • 4.4 โ€” โœ”
  • 4.5 โ€” โœ”

she ate every single column, no notes ๐Ÿ‘‘

GL_HALF_FLOAT

  • 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 GL_HALF_FLOAT sat out 2.0 and 2.1 and then showed up in 3.0 like a glow-up montage ๐Ÿฆ‹


๐Ÿซถ SEE ALSO ๐Ÿซถ

your little friend group of related calls, go say hi:

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

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 ยฉ 1991-2006 Silicon Graphics, Inc.


and that's the whole page, bestie!! ๐ŸŽ€โœจ

okay final sign-off moment ๐ŸŒธ this gem's source line is a placeholder โ€” it literally says [FIXME: source] ๐Ÿ™ˆ โ€” and it's dated 08/09/2021, filed under GLTEXIMAGE2D(3G). so like, yeah, vintage-adjacent but still serving ๐Ÿ’… bye bestie, go make some textures!! ๐Ÿฆ‹๐Ÿ’–๐Ÿ”ฅ

๐Ÿ“ฆ where this page comes from