GLTEXIMAGE1D(3G)

🌈 GLTEXIMAGE1D(3G) 🌈

okay so this is the GLTEXIMAGE1D(3G) page, and yes the header still has a little [FIXME: manual] situation going on β€” we move regardless πŸ’…

πŸŽ€ NAME πŸŽ€

glTexImage1D β€” specify a one-dimensional texture image ✨

πŸ’– C SPECIFICATION πŸ’–

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

πŸ¦‹ PARAMETERS πŸ¦‹

  • target β€” specifies the target texture. It must be GL_TEXTURE_1D or GL_PROXY_TEXTURE_1D.
  • level β€” specifies the level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.
  • internalformat β€” specifies the number of color components in the texture. It 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 β€” specifies the width of the texture image. All implementations support texture images that are at least 1024 texels wide. The height of the 1D texture image is 1.
  • border β€” this value must be 0. fr fr, it's 0.
  • format β€” specifies 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 β€” specifies 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 β€” specifies 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 one-dimensional texturing, call glEnable() and glDisable with argument GL_TEXTURE_1D.

Texture images are defined with glTexImage1D. The arguments describe the parameters of the texture image, such as width, width of the border, level-of-detail number (see glTexParameter()), and the internal resolution and format used to store the image. The last three arguments describe how the image is represented in memory.

If target is GL_PROXY_TEXTURE_1D, 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_1D, 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 left end of the texture array. Subsequent elements progress left-to-right through the remaining texels in the texture array. The final element corresponds to the right end of the texture array. ✨

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 single 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].
  • GL_DEPTH_COMPONENT β€” each element is a single depth value. The GL converts it to floating point and clamps 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 πŸ“Š

The columns are Base Internal Format, RGBA, Depth and Stencil Values, and Internal Components:

  • 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, this is the big one β€” the sized internal formats table. Read it like a menu πŸ“. Every row has a Sized Internal Format, a Base Internal Format, and then some bit counts: Red Bits, Green Bits, Blue Bits, Alpha Bits, and Shared Bits.

Quick vibe check before you scroll: the Shared Bits column is empty for literally every single row here πŸ’€. Not one of them fills it in. So I'm just gonna skip writing "Shared Bits: β€”" fifty times and you can trust me that it's blank all the way down 🫢.

Also, the bit counts are written exactly how the table writes them β€” like s8, s16, ui10, ui2, f16 β€” so don't come for me, I'm copying the table's whole aesthetic πŸ’….

  • GL_R8 β€” Base Internal Format GL_RED; Red Bits 8
  • GL_R8_SNORM β€” Base Internal Format GL_RED; Red Bits s8
  • GL_R16 β€” Base Internal Format GL_RED; Red Bits 16
  • GL_R16_SNORM β€” Base Internal Format GL_RED; Red Bits s16
  • GL_RG8 β€” Base Internal Format GL_RG; Red Bits 8, Green Bits 8
  • GL_RG8_SNORM β€” Base Internal Format GL_RG; Red Bits s8, Green Bits s8
  • GL_RG16 β€” Base Internal Format GL_RG; Red Bits 16, Green Bits 16
  • GL_RG16_SNORM β€” Base Internal Format GL_RG; Red Bits s16, Green Bits s16
  • GL_R3_G3_B2 β€” Base Internal Format GL_RGB; Red Bits 3, Green Bits 3, Blue Bits 2
  • GL_RGB4 β€” Base Internal Format GL_RGB; Red Bits 4, Green Bits 4, Blue Bits 4
  • GL_RGB5 β€” Base Internal Format GL_RGB; Red Bits 5, Green Bits 5, Blue Bits 5
  • GL_RGB8 β€” Base Internal Format GL_RGB; Red Bits 8, Green Bits 8, Blue Bits 8
  • GL_RGB8_SNORM β€” Base Internal Format GL_RGB; Red Bits s8, Green Bits s8, Blue Bits s8
  • GL_RGB10 β€” Base Internal Format GL_RGB; Red Bits 10, Green Bits 10, Blue Bits 10
  • GL_RGB12 β€” Base Internal Format GL_RGB; Red Bits 12, Green Bits 12, Blue Bits 12
  • GL_RGB16_SNORM β€” Base Internal Format GL_RGB; Red Bits 16, Green Bits 16, Blue Bits 16
  • GL_RGBA2 β€” Base Internal Format GL_RGB; Red Bits 2, Green Bits 2, Blue Bits 2, Alpha Bits 2
  • GL_RGBA4 β€” Base Internal Format GL_RGB; Red Bits 4, Green Bits 4, Blue Bits 4, Alpha Bits 4
  • GL_RGB5_A1 β€” Base Internal Format GL_RGBA; Red Bits 5, Green Bits 5, Blue Bits 5, Alpha Bits 1
  • GL_RGBA8 β€” Base Internal Format GL_RGBA; Red Bits 8, Green Bits 8, Blue Bits 8, Alpha Bits 8
  • GL_RGBA8_SNORM β€” Base Internal Format GL_RGBA; Red Bits s8, Green Bits s8, Blue Bits s8, Alpha Bits s8
  • GL_RGB10_A2 β€” Base Internal Format GL_RGBA; Red Bits 10, Green Bits 10, Blue Bits 10, Alpha Bits 2
  • GL_RGB10_A2UI β€” Base Internal Format GL_RGBA; Red Bits ui10, Green Bits ui10, Blue Bits ui10, Alpha Bits ui2
  • GL_RGBA12 β€” Base Internal Format GL_RGBA; Red Bits 12, Green Bits 12, Blue Bits 12, Alpha Bits 12
  • GL_RGBA16 β€” Base Internal Format GL_RGBA; Red Bits 16, Green Bits 16, Blue Bits 16, Alpha Bits 16
  • GL_SRGB8 β€” Base Internal Format GL_RGB; Red Bits 8, Green Bits 8, Blue Bits 8
  • GL_SRGB8_ALPHA8 β€” Base Internal Format GL_RGBA; Red Bits 8, Green Bits 8, Blue Bits 8, Alpha Bits 8
  • GL_R16F β€” Base Internal Format GL_RED; Red Bits f16
  • GL_RG16F β€” format GL_RG Β· R: f16 Β· G: f16 🌸
  • GL_RGB16F β€” format GL_RGB Β· R: f16 Β· G: f16 Β· B: f16 πŸ’–
  • GL_RGBA16F β€” format GL_RGBA Β· R: f16 Β· G: f16 Β· B: f16 Β· A: f16 ✨
  • GL_R32F β€” format GL_RED Β· R: f32 πŸ¦‹
  • GL_RG32F β€” format GL_RG Β· R: f32 Β· G: f32 πŸ’œ
  • GL_RGB32F β€” format GL_RGB Β· R: f32 Β· G: f32 Β· B: f32 πŸ”₯
  • GL_RGBA32F β€” format GL_RGBA Β· R: f32 Β· G: f32 Β· B: f32 Β· A: f32 πŸ‘‘
  • GL_R11F_G11F_B10F β€” format GL_RGB Β· R: f11 Β· G: f11 Β· B: f10 πŸŽ€
  • GL_RGB9_E5 β€” format GL_RGB Β· R: 9 Β· G: 9 Β· B: 9 Β· shared exponent: 5 ⭐

okay now we're in the integer era of the table and honestly it's a whole aesthetic πŸ’… signed ones get an i, unsigned ones get a ui, and the prefix is literally just how many bits you're working with. no notes, she's consistent.

  • GL_R8I β€” format GL_RED Β· R: i8 πŸ’€
  • GL_R8UI β€” format GL_RED Β· R: ui8 🌈
  • GL_R16I β€” format GL_RED Β· R: i16 πŸ“
  • GL_R16UI β€” format GL_RED Β· R: ui16 🧚
  • GL_R32I β€” format GL_RED Β· R: i32 🫢
  • GL_R32UI β€” format GL_RED Β· R: ui32 πŸ’–

two channels now, we're levelling up bestie:

  • GL_RG8I β€” format GL_RG Β· R: i8 Β· G: i8 πŸ¦‹
  • GL_RG8UI β€” format GL_RG Β· R: ui8 Β· G: ui8 🌸
  • GL_RG16I β€” format GL_RG Β· R: i16 Β· G: i16 πŸ’œ
  • GL_RG16UI β€” format GL_RG Β· R: ui16 Β· G: ui16 ✨
  • GL_RG32I β€” format GL_RG Β· R: i32 Β· G: i32 πŸ”₯
  • GL_RG32UI β€” format GL_RG Β· R: ui32 Β· G: ui32 πŸ‘‘

three channels, three whole moods:

  • GL_RGB8I β€” format GL_RGB Β· R: i8 Β· G: i8 Β· B: i8 πŸŽ€
  • GL_RGB8UI β€” format GL_RGB Β· R: ui8 Β· G: ui8 Β· B: ui8 ⭐
  • GL_RGB16I β€” format GL_RGB Β· R: i16 Β· G: i16 Β· B: i16 πŸ’€
  • GL_RGB16UI β€” format GL_RGB Β· R: ui16 Β· G: ui16 Β· B: ui16 🌈
  • GL_RGB32I β€” format GL_RGB Β· R: i32 Β· G: i32 Β· B: i32 πŸ“
  • GL_RGB32UI β€” format GL_RGB Β· R: ui32 Β· G: ui32 Β· B: ui32 🧚

and the full four-channel set, alpha included, we love a complete squad 🫢

  • GL_RGBA8I β€” format GL_RGBA Β· R: i8 Β· G: i8 Β· B: i8 Β· A: i8 πŸ’–
  • GL_RGBA8UI β€” format GL_RGBA Β· R: ui8 Β· G: ui8 Β· B: ui8 Β· A: ui8 πŸ¦‹
  • GL_RGBA16I β€” format GL_RGBA Β· R: i16 Β· G: i16 Β· B: i16 Β· A: i16 🌸
  • GL_RGBA16UI β€” format GL_RGBA Β· R: ui16 Β· G: ui16 Β· B: ui16 Β· A: ui16 πŸ’œ

…and the internal-format table (Table 2) is still serving looks, bestie. Last two rows, coming right up:

  • GL_RGBA32I β€” GL_RGBA Β· i32 Β· i32 Β· i32 Β· i32 Β· trailing cell empty
  • GL_RGBA32UI β€” GL_RGBA Β· ui32 Β· ui32 Β· ui32 Β· ui32 Β· trailing cell empty

Table 3. Compressed Internal Formats

  • GL_COMPRESSED_RED β€” base internal format GL_RED β€” type Generic
  • GL_COMPRESSED_RG β€” base internal format GL_RG β€” type Generic
  • GL_COMPRESSED_RGB β€” base internal format GL_RGB β€” type Generic
  • GL_COMPRESSED_RGBA β€” base internal format GL_RGBA β€” type Generic
  • GL_COMPRESSED_SRGB β€” base internal format GL_RGB β€” type Generic
  • GL_COMPRESSED_SRGB_ALPHA β€” base internal format GL_RGBA β€” type Generic
  • GL_COMPRESSED_RED_RGTC1 β€” base internal format GL_RED β€” type Specific
  • GL_COMPRESSED_SIGNED_RED_RGTC1 β€” base internal format GL_RED β€” type Specific
  • GL_COMPRESSED_RG_RGTC2 β€” base internal format GL_RG β€” type Specific
  • GL_COMPRESSED_SIGNED_RG_RGTC2 β€” base internal format GL_RG β€” type Specific
  • GL_COMPRESSED_RGBA_BPTC_UNORM β€” base internal format GL_RGBA β€” type Specific
  • GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM β€” base internal format GL_RGBA β€” type Specific
  • GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT β€” base internal format GL_RGB β€” type Specific
  • GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT β€” base internal format GL_RGB β€” type 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. periodt, that's the whole compression glow-up.

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 s + 0.055 ) / 1.055 )^2.4     if c s > 0.04045

Assume c s is the sRGB component in the range [0,1]. math queen behavior, honestly. ✨

Use the GL_PROXY_TEXTURE_1D 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. like, it's a vibe check for your texture. 🫢

A one-component texture image uses only the red component of the RGBA color from data. A two-component image uses the R and A values. A three-component image uses the R, G, and B values. A four-component image uses all of the RGBA components. yes, two-component really is R and A β€” no cap.

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

  • glPixelStore() modes affect texture images. little settings gremlins, always affecting something.
  • data may be a null pointer. In this case texture memory is allocated to accommodate a texture of width width. You can then download subtextures to initialize the texture memory. The image is undefined if the program tries to apply an uninitialized portion of the texture image to a primitive. undefined behavior alert β€” do not romanticize it. πŸ’€
  • glTexImage1D specifies the one-dimensional texture for the current texture unit, specified with glActiveTexture(). current texture unit says hi.
  • GL_STENCIL_INDEX may be used for format only if the GL version is 4.4 or higher. version check before you even try it, bestie.

🚨 ERRORS

  • GL_INVALID_ENUM is generated if target is not GL_TEXTURE_1D or GL_PROXY_TEXTURE_1D.
  • GL_INVALID_ENUM is generated if format is not an accepted format constant. Format constants other than GL_STENCIL_INDEX are accepted.
  • GL_INVALID_ENUM is generated if type is not a type constant.
  • GL_INVALID_VALUE is generated if level is less than 0.
  • 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.
  • GL_INVALID_VALUE is generated if internalformat is not one of the accepted resolution and format symbolic constants.
  • GL_INVALID_VALUE is generated if width is less than 0 or greater than GL_MAX_TEXTURE_SIZE.
  • GL_INVALID_VALUE is generated if border is not 0.
  • GL_INVALID_OPERATION is generated if type is one of GL_UNSIGNED_BYTE_3_3_2, GL_UNSIGNED_BYTE_2_3_3_REV, GL_UNSIGNED_SHORT_5_6_5, or GL_UNSIGNED_SHORT_5_6_5_REV and format is not GL_RGB.
  • GL_INVALID_OPERATION is generated 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, or GL_UNSIGNED_INT_2_10_10_10_REV and format is neither GL_RGBA nor GL_BGRA.
  • GL_INVALID_OPERATION is generated if format is GL_DEPTH_COMPONENT and internalformat is not GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, or GL_DEPTH_COMPONENT32.
  • GL_INVALID_OPERATION is generated if internalformat is GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24, or GL_DEPTH_COMPONENT32, and format is not GL_DEPTH_COMPONENT.
  • GL_INVALID_OPERATION is generated 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.
  • GL_INVALID_OPERATION is generated 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.
  • GL_INVALID_OPERATION is generated 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.
error list is long, but she's thorough. read it. memorize it. live it. πŸ’…

πŸ” ASSOCIATED GETS

  • glGetTexImage()
  • glGet() with argument GL_PIXEL_UNPACK_BUFFER_BINDING

✨ VERSION SUPPORT ✨

Okay bestie, vibe check on which OpenGL versions are gonna play nice with these features πŸ’… (the original lays this out as a big grid, so here it is as a list β€” same facts, way less squinting):

  • glTexImage1D β€” slay in every version: 2.0 βœ”, 2.1 βœ”, 3.0 βœ”, 3.1 βœ”, 3.2 βœ”, 3.3 βœ”, 4.0 βœ”, 4.1 βœ”, 4.2 βœ”, 4.3 βœ”, 4.4 βœ”, 4.5 βœ”. Iconic, no notes. πŸ‘‘
  • GL_HALF_FLOAT β€” she's late to the party, and that's fine: 2.0 ✘ (no), 2.1 ✘ (still no), then 3.0 βœ”, 3.1 βœ”, 3.2 βœ”, 3.3 βœ”, 4.0 βœ”, 4.1 βœ”, 4.2 βœ”, 4.3 βœ”, 4.4 βœ”, 4.5 βœ”. So like, from 3.0 onward she's fully main character energy. 🌸

πŸ¦‹ SEE ALSO πŸ¦‹

Go touch grass with her friends, fr fr β€” every one of these is literally right there:

  • glActiveTexture()
  • glCompressedTexImage1D()
  • glCompressedTexSubImage1D()
  • glCopyTexImage1D()
  • glCopyTexSubImage1D()
  • glGetCompressedTexImage()
  • glPixelStore()
  • glTexImage2D()
  • 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 β€” you ate. 🫢

Sign-off szn: the source shows up as [FIXME: source] (yes, literally a FIXME, we love a humble king πŸ™ˆ), it's dated 08/09/2021, and the manual page is GLTEXIMAGE1D(3G). Go forth and texture your 1D images. πŸ’–βœ¨

πŸ“¦ where this page comes from