GLPIXELSTORE(3G)
π GLPIXELSTORE(3G) π
okay bestie, welcome to glPixelStore β the little function that decides how your pixel bytes get packed up and unpacked, and honestly it's giving "underrated icon" because when it's wrong, everything looks cursed. the header on this bad boy literally reads GLPIXELSTORE(3G) with a [FIXME: manual] sitting in the middle of it, and we're just gonna let that be iconic. π
β¨ NAME β¨
glPixelStore β set pixel storage modes. that's it. that's the whole vibe. π
πΈ C SPECIFICATION πΈ
void glPixelStoref(GLenum pname, GLfloat param);
void glPixelStorei(GLenum pname, GLint param);
two flavors, one for float girlies and one for int girlies. pick your fighter. π«Ά
π PARAMETERS π
pnameβ the symbolic name of the parameter you wanna set. and listen, there's a lot of them: six values affect the packing of pixel data into memory:GL_PACK_SWAP_BYTES,GL_PACK_LSB_FIRST,GL_PACK_ROW_LENGTH,GL_PACK_IMAGE_HEIGHT,GL_PACK_SKIP_PIXELS,GL_PACK_SKIP_ROWS,GL_PACK_SKIP_IMAGES, andGL_PACK_ALIGNMENT. and then six more affect the unpacking of pixel data from memory:GL_UNPACK_SWAP_BYTES,GL_UNPACK_LSB_FIRST,GL_UNPACK_ROW_LENGTH,GL_UNPACK_IMAGE_HEIGHT,GL_UNPACK_SKIP_PIXELS,GL_UNPACK_SKIP_ROWS,GL_UNPACK_SKIP_IMAGES, andGL_UNPACK_ALIGNMENT. yes the count says six and the list says eight, we are simply not addressing that today, moving on π«Άparamβ the value thatpnamegets set to. the actual number. the substance. π
π¦ DESCRIPTION π¦
glPixelStore sets pixel storage modes that affect how subsequent glReadPixels() behaves, plus the unpacking of texture patterns β and here comes the whole squad: glTexImage1D(), glTexImage2D(), glTexImage3D(), glTexSubImage1D(), glTexSubImage2D(), glTexSubImage3D(), glCompressedTexImage1D(), glCompressedTexImage2D(), glCompressedTexImage3D(), glCompressedTexSubImage1D(), glCompressedTexSubImage2D() or glCompressedTexSubImage1D(). (yes, glCompressedTexSubImage1D() is in there twice. she said "and I'll say it again." π)
pname is a symbolic constant saying which parameter you're setting, and param is the brand new value. Six of the twelve storage parameters affect how pixel data is returned to client memory. they are, in order, and yes I'm listing every single one:
π the PACK girlies (data going OUT to client memory) π
GL_PACK_SWAP_BYTESβ if true, byte ordering for multibyte color components, depth components, or stencil indices gets reversed. so if a four-byte component consists of bytesb 0,b 1,b 2,b 3, it lands in memory asb 3,b 2,b 1,b 0whenGL_PACK_SWAP_BYTESis true. and lowkey important:GL_PACK_SWAP_BYTEShas no effect on the memory order of components within a pixel, only on the order of bytes within components or indices. example time: the three components of aGL_RGBformat pixel are always stored with red first, green second, and blue third, no matter whatGL_PACK_SWAP_BYTESis doing. red stays first. she's not moving. πGL_PACK_LSB_FIRSTβ if true, bits are ordered within a byte from least significant to most significant; otherwise, the first bit in each byte is the most significant one. little-endian energy vs. big-endian energy, byte edition. βGL_PACK_ROW_LENGTHβ if greater than 0,GL_PACK_ROW_LENGTHdefines the number of pixels in a row. if the first pixel of a row is placed at locationpin memory, then the location of the first pixel of the next row is obtained by skipping
k = n β’ l a s β’ s β’ n β’ l a β’ s >= a s < a
components or indices, where n is the number of components or indices in a pixel, l is the number of pixels in a row (GL_PACK_ROW_LENGTH if it is greater than 0, the width argument to the pixel routine otherwise), a is the value of GL_PACK_ALIGNMENT, and s is the size, in bytes, of a single component (if a < s, then it is as if a = s). in the case of 1-bit values, the location of the next row is obtained by skipping
k = 8 β’ a β’ n β’ l 8 β’ a
components or indices. (and no, that's genuinely how the formula came out of the typesetter β I'm preserving the crime scene, not fixing it π)
the word component in this description refers to the nonindex values red, green, blue, alpha, and depth. storage format GL_RGB, for example, has three components per pixel: first red, then green, and finally blue. πΈ
GL_PACK_IMAGE_HEIGHTβ if greater than 0,GL_PACK_IMAGE_HEIGHTdefines the number of pixels in an image three-dimensional texture volume, where "image" is defined by all pixels sharing the same third dimension index. if the first pixel of a row is placed at locationpin memory, then the location of the first pixel of the next row is obtained by skipping
k = n β’ l β’ h a s β’ s β’ n β’ l β’ h a β’ s >= a s < a
components or indices, where n is the number of components or indices in a pixel, l is the number of pixels in a row (GL_PACK_ROW_LENGTH if it is greater than 0, the width argument to glTexImage3D() otherwise), h is the number of rows in a pixel image (GL_PACK_IMAGE_HEIGHT if it is greater than 0, the height argument to the glTexImage3D() routine otherwise), a is the value of GL_PACK_ALIGNMENT, and s is the size, in bytes, of a single component (if a < s, then it is as if a = s).
again: the word component here refers to the nonindex values red, green, blue, alpha, and depth. storage format GL_RGB, for example, has three components per pixel: first red, then green, and finally blue. π§
GL_PACK_SKIP_PIXELS,GL_PACK_SKIP_ROWS, andGL_PACK_SKIP_IMAGESβ these are literally just a convenience for the programmer, bestie. they provide no functionality that can't be duplicated simply by incrementing the pointer passed toglReadPixels(). settingGL_PACK_SKIP_PIXELStoiis equivalent to incrementing the pointer byi ncomponents or indices, wherenis the number of components or indices in each pixel. settingGL_PACK_SKIP_ROWStojis equivalent to incrementing the pointer byj mcomponents or indices, wheremis the number of components or indices per row, as just computed in theGL_PACK_ROW_LENGTHsection. settingGL_PACK_SKIP_IMAGEStokis equivalent to incrementing the pointer byk p, wherepis the number of components or indices per image, as computed in theGL_PACK_IMAGE_HEIGHTsection. it's giving "we built you a shortcut but also the shortcut is just maths." π₯GL_PACK_ALIGNMENTβ specifies the alignment requirements for the start of each pixel row in memory. the allowable values are1(byte-alignment),2(rows aligned to even-numbered bytes),4(word-alignment), and8(rows start on double-word boundaries). that's the whole menu, no substitutions. π
π the UNPACK girlies (data coming IN from client memory) π
the other six of the twelve storage parameters affect how pixel data is read from client memory. these values are significant for glTexImage1D(), glTexImage2D(), glTexImage3D(), glTexSubImage1D(), glTexSubImage2D(), and glTexSubImage3D(). and here they are:
GL_UNPACK_SWAP_BYTESβ if true, byte ordering for multibyte color components, depth components, or stencil indices is reversed. that is, if a four-byte component consists of bytesb 0,b 1,b 2,b 3, it is taken from memory asb 3,b 2,b 1,b 0ifGL_UNPACK_SWAP_BYTESis true. and same as her PACK sister:GL_UNPACK_SWAP_BYTEShas no effect on the memory order of components within a pixel, only on the order of bytes within components or indices. for example, the three components of aGL_RGBformat pixel are always stored with red first, green second, and blue third, regardless of the value ofGL_UNPACK_SWAP_BYTES. red. stays. first. periodt. πGL_UNPACK_LSB_FIRSTβ if true, bits are ordered within a byte from least significant to most significant; otherwise, the first bit in each byte is the most significant one. πGL_UNPACK_ROW_LENGTHβ if greater than 0,GL_UNPACK_ROW_LENGTHdefines the number of pixels in a row. if the first pixel of a row is placed at locationpin memory, then the location of the first pixel of the next row is obtained by skipping
k = n β’ l a s β’ s β’ n β’ l a β’ s >= a s < a
components or indices, where n is the number of components or indices in a pixel, l is the number of pixels in a row (GL_UNPACK_ROW_LENGTH if it is greater than 0, the width argument to the pixel routine otherwise), a is the value of GL_UNPACK_ALIGNMENT, and s is the size, in bytes, of a single component (if a < s, then it is as if a = s). in the case of 1-bit values, the location of the next row is obtained by skipping
k = 8 β’ a β’ n β’ l 8 β’ a
components or indices.
the word component in this description refers to the nonindex values red, green, blue, alpha, and depth. storage format GL_RGB, for example, has three components per pixel: first red, then green, and finally blue. π
GL_UNPACK_IMAGE_HEIGHTβ if greater than 0,GL_UNPACK_IMAGE_HEIGHTdefines the number of pixels in an image of a three-dimensional texture volume, where "image" is defined by all pixel sharing the same third dimension index. if the first pixel of a row is placed at locationpin memory, then the location of the first pixel of the next row is obtained by skipping
k = n β’ l β’ h a s β’ s β’ n β’ l β’ h a β’ s >= a s < a
components or indices, where n is the number of components or indices in a pixel, l is the number of pixels in a row (GL_UNPACK_ROW_LENGTH if it is greater than 0, the width argument to glTexImage3D() otherwise), h is the number of rows in an image (GL_UNPACK_IMAGE_HEIGHT if it is greater than 0, the height argument to glTexImage3D() otherwise), a is the value of GL_UNPACK_ALIGNMENT, and s is the size, in bytes, of a single component (if a < s, then it is as if a = s).
the word component in this description refers to the nonindex values red, green, blue, alpha, and depth. storage format GL_RGB, for example, has three components per pixel: first red, then green, and finally blue. πΈ
GL_UNPACK_SKIP_PIXELSandGL_UNPACK_SKIP_ROWSβ convenience for the programmer, no cap. they provide no functionality that cannot be duplicated by incrementing the pointer passed toglTexImage1D(),glTexImage2D(),glTexSubImage1D()orglTexSubImage2D(). settingGL_UNPACK_SKIP_PIXELStoiis equivalent to incrementing the pointer byi ncomponents or indices, wherenis the number of components or indices in each pixel. settingGL_UNPACK_SKIP_ROWStojis equivalent to incrementing the pointer byj kcomponents or indices, wherekis the number of components or indices per row, as just computed in theGL_UNPACK_ROW_LENGTHsection. π¦GL_UNPACK_ALIGNMENTβ specifies the alignment requirements for the start of each pixel row in memory. the allowable values are1(byte-alignment),2(rows aligned to even-numbered bytes),4(word-alignment), and8(rows start on double-word boundaries). same menu, different section. β
okay so the next thing on the page is a table situation: the following table gives the type, initial value, and range of valid values for each storage parameter that can be set with glPixelStore β and that table is coming at you in the next part, so don't go anywhere, we're not done here yet ππ
okay so before we get into the chaos, here's the full roster of every pname you can throw at these functions β type, where it starts out, and what it's allowed to be. bookmark this bestie, it's the whole vibe check π
GL_PACK_SWAP_BYTESβ typeboolean, initial valuefalse, valid rangetrueorfalseGL_PACK_LSB_FIRSTβ typeboolean, initial valuefalse, valid rangetrueorfalseGL_PACK_ROW_LENGTHβ typeinteger, initial value0, valid range0toβGL_PACK_IMAGE_HEIGHTβ typeinteger, initial value0, valid range0toβGL_PACK_SKIP_ROWSβ typeinteger, initial value0, valid range0toβGL_PACK_SKIP_PIXELSβ typeinteger, initial value0, valid range0toβGL_PACK_SKIP_IMAGESβ typeinteger, initial value0, valid range0toβGL_PACK_ALIGNMENTβ typeinteger, initial value4, valid range1,2,4, or8GL_UNPACK_SWAP_BYTESβ typeboolean, initial valuefalse, valid rangetrueorfalseGL_UNPACK_LSB_FIRSTβ typeboolean, initial valuefalse, valid rangetrueorfalseGL_UNPACK_ROW_LENGTHβ typeinteger, initial value0, valid range0toβGL_UNPACK_IMAGE_HEIGHTβ typeinteger, initial value0, valid range0toβGL_UNPACK_SKIP_ROWSβ typeinteger, initial value0, valid range0toβGL_UNPACK_SKIP_PIXELSβ typeinteger, initial value0, valid range0toβGL_UNPACK_SKIP_IMAGESβ typeinteger, initial value0, valid range0toβGL_UNPACK_ALIGNMENTβ typeinteger, initial value4, valid range1,2,4, or8
see how the pack ones and the unpack ones are basically twins? π§ one set is for reading out, one set is for feeding in, and they both start at the exact same defaults. iconic symmetry, honestly.
so like, glPixelStoref can be used to set any pixel store parameter. cute, right? and if the parameter type is boolean, then if param is 0, the parameter is set to false β otherwise it's set to true. no in-between, it's giving binary. β¨
and if pname is an integer type parameter, param gets rounded to the nearest integer. so like, don't stress about handing it a float, it'll just snap to the closest whole number. π«Ά
likewise, glPixelStorei can also be used to set any of the pixel store parameters. same deal: boolean parameters are set to false if param is 0 and true otherwise. periodt. π
π ERRORS π
okay so here's where it can go wrong, and ngl it will if you're not paying attention:
GL_INVALID_ENUMis generated ifpnameis not an accepted value. basically if you made up a name, bestie, it's not gonna fly πGL_INVALID_VALUEis generated if a negative row length, pixel skip, or row skip value is specified, or if alignment is specified as other than1,2,4, or8. so likeβ¦ negative skips? absolutely not. and that alignment value has to be one of those four, no exceptions. π
fr fr, double-check your alignment constant before you ship.1,2,4, or8. that's the whole list. don't be the person who passes3and then stares at the error. π
π ASSOCIATED GETS π
you wanna check what a parameter is currently set to? there's a getter for literally every single one of them, no cap:
glGet()with argumentGL_PACK_SWAP_BYTESglGet()with argumentGL_PACK_LSB_FIRSTglGet()with argumentGL_PACK_ROW_LENGTHglGet()with argumentGL_PACK_IMAGE_HEIGHTglGet()with argumentGL_PACK_SKIP_ROWSglGet()with argumentGL_PACK_SKIP_PIXELSglGet()with argumentGL_PACK_SKIP_IMAGESglGet()with argumentGL_PACK_ALIGNMENTglGet()with argumentGL_UNPACK_SWAP_BYTESglGet()with argumentGL_UNPACK_LSB_FIRSTglGet()with argumentGL_UNPACK_ROW_LENGTHglGet()with argumentGL_UNPACK_IMAGE_HEIGHTglGet()with argumentGL_UNPACK_SKIP_ROWSglGet()with argumentGL_UNPACK_SKIP_PIXELSglGet()with argumentGL_UNPACK_SKIP_IMAGESglGet()with argumentGL_UNPACK_ALIGNMENT
sixteen parameters, sixteen getters. one-to-one. it's giving organized. π
π VERSION SUPPORT π
good news bestie, these two functions are everywhere. like, everywhere everywhere. here's the receipts, and yes, the answer to every single column is a big fat β:
glPixelStorefβ supported in OpenGL2.0β,2.1β,3.0β,3.1β,3.2β,3.3β,4.0β,4.1β,4.2β,4.3β,4.4β,4.5βglPixelStoreiβ supported in OpenGL2.0β,2.1β,3.0β,3.1β,3.2β,3.3β,4.0β,4.1β,4.2β,4.3β,4.4β,4.5β
twelve out of twelve for both. full sweep. main character energy from 2.0 all the way through 4.5 πβ¨
and there's still more page coming, so don't go anywhere π¦
π SEE ALSO
okay so if you wanna go deeper (and like, you should), these are the besties this page is linked to β go read up on all of them:
glReadPixels()glTexImage1D()glTexImage2D()glTexImage3D()glTexSubImage1D()glTexSubImage2D()glTexSubImage3D()glCompressedTexImage1D()glCompressedTexImage2D()glCompressedTexImage3D()glCompressedTexSubImage1D()glCompressedTexSubImage2D()glCompressedTexSubImage1D()
(and yes, glCompressedTexSubImage1D() is listed twice in the original β iconic of them, no cap, not me fixing it π
)
π COPYRIGHT
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 (round two, bestie π«Ά)
Copyright Β© 1991-2006 Silicon Graphics, Inc.
Copyright Β© 2010-2014 Khronos Group
and that's a wrap on GLPIXELSTORE(3G)!! πβ¨ you made it to the end, I'm so proud of you fr fr π the source for this one is literally just [FIXME: source] (lol, slay), it's dated 08/09/2021, and it goes by GLPIXELSTORE(3G) β go forth and store those pixels, 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