GLPIXELSTORE(3G)
๐ GLPIXELSTORE(3G) โ okay bestie, let's talk pixel storage ๐
So this is the GLPIXELSTORE(3G) page โ manual section 3G, GL family, and no cap it's a beefy one. Grab a lil snack ๐ because we're about to get deep into how OpenGL shoves pixels in and out of memory.
โจ NAME โจ
glPixelStoref, glPixelStorei โ set pixel storage modes ๐
๐ง C SPECIFICATION ๐ง
Like, literally here's the signatures, keep them exactly as they are:
void glPixelStoref( GLenum pname,
GLfloat param )
void glPixelStorei( GLenum pname,
GLint param )
delim $$
(that delim $$ line is just a typesetting thing for the math below, don't panic ๐ซถ)
๐ PARAMETERS ๐
pnameโ the symbolic name of the parameter you're setting, iykyk. 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 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 it says six and then lists eight, she's an icon, we move ๐)paramโ the value thatpnamegets set to. Simple as that, periodt.
๐ธ DESCRIPTION ๐ธ
glPixelStore sets pixel storage modes โ and these modes affect the operation of all the subsequent glDrawPixels and glReadPixels calls, plus the unpacking of polygon stipple patterns (see glPolygonStipple), bitmaps (see glBitmap), and texture patterns (see glTexImage1D, glTexImage2D, glTexImage3D, glTexSubImage1D, glTexSubImage2D, glTexSubImage3D). ๐ฆ
And listen โ additionally, if the GL_ARB_imaging extension is supported, pixel storage modes affect convolution filters (see glConvolutionFilter1D, glConvolutionFilter2D, and glSeparableFilter2D), color table (see glColorTable, and glColorSubTable), and unpacking histogram (See glHistogram), and minmax (See glMinmax) data. Like, the whole extended family shows up. ๐
pname is a symbolic constant indicating the parameter to be set, and param is the new value. Six of the twelve storage parameters affect how pixel data is returned to client memory. They are as follows:
๐ซ GL_PACK_SWAP_BYTES
If true, byte ordering for multibyte color components, depth components, color indices, or stencil indices is reversed. That is, if a four-byte component consists of bytes $b sub 0$, $b sub 1$, $b sub 2$, $b sub 3$, it is stored in memory as $b sub 3$, $b sub 2$, $b sub 1$, $b sub 0$ if GL_PACK_SWAP_BYTES is true.
โ ๏ธ Important vibe check: GL_PACK_SWAP_BYTES has 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 a GL_RGB pixel are always stored with red first, green second, and blue third, regardless of the value of GL_PACK_SWAP_BYTES. RGB stays RGB, bestie.
๐ซ 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. This parameter is significant for bitmap data only. ๐
๐ซ GL_PACK_ROW_LENGTH
If greater than 0, GL_PACK_ROW_LENGTH defines the number of pixels in a row. If the first pixel of a row is placed at location $p$ in memory, then the location of the first pixel of the next row is obtained by skipping
$k ~=~~ left { ^ lpile { n l above {a over s left ceiling { s
n l } over a right ceiling}} ~~ lpile {s ~>=~ a above 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 left ceiling { n l } over { 8 a } ^ right ceiling$
components or indices.
The word component in this description refers to the nonindex values red, green, blue, alpha, and depth. Storage 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_HEIGHT defines 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 location $p$ in memory, then the location of the first pixel of the next row is obtained by skipping
$k ~=~~ left { ~ lpile { n l h above {a over s left ceiling {
s n l h }
over a ^ right ceiling}} ~~ lpile {s ~>=~ a above 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$).
The word component in this description refers to the nonindex values red, green, blue, alpha, and depth. Storage GL_RGB, for example, has three components per pixel: first red, then green, and finally blue. ๐
๐ซ GL_PACK_SKIP_PIXELS, GL_PACK_SKIP_ROWS, and GL_PACK_SKIP_IMAGES
These values are provided as a convenience to the programmer; they provide no functionality that cannot be duplicated simply by incrementing the pointer passed to glReadPixels.
- Setting
GL_PACK_SKIP_PIXELSto $i$ is equivalent to incrementing the pointer by $i n$ components or indices, where $n$ is the number of components or indices in each pixel. - Setting
GL_PACK_SKIP_ROWSto $j$ is equivalent to incrementing the pointer by $j m$ components or indices, where $m$ is the number of components or indices per row, as just computed in theGL_PACK_ROW_LENGTHsection. - Setting
GL_PACK_SKIP_IMAGESto $k$ is equivalent to incrementing the pointer by $k p$, where $p$ is the number of components or indices per image, as computed in theGL_PACK_IMAGE_HEIGHTsection.
๐ซ GL_PACK_ALIGNMENT
Specifies the alignment requirements for the start of each pixel row in memory. The allowable values are:
1โ byte-alignment2โ rows aligned to even-numbered bytes4โ word-alignment8โ rows start on double-word boundaries
Okay so โ the other six of the twelve storage parameters affect how pixel data is read from client memory. These values are significant for glDrawPixels, glTexImage1D, glTexImage2D, glTexImage3D, glTexSubImage1D, glTexSubImage2D, glTexSubImage3D, glBitmap, and glPolygonStipple.
Additionally, if the GL_ARB_imaging extension is supported: glColorTable, glColorSubTable, glConvolutionFilter1D, glConvolutionFilter2D, and glSeparableFilter2D. They are as follows:
๐ฆ GL_UNPACK_SWAP_BYTES
If true, byte ordering for multibyte color components, depth components, color indices, or stencil indices is reversed. That is, if a four-byte component consists of bytes $b sub 0$, $b sub 1$, $b sub 2$, $b sub 3$, it is taken from memory as $b sub 3$, $b sub 2$, $b sub 1$, $b sub 0$ if GL_UNPACK_SWAP_BYTES is true.
โ ๏ธ Same energy as the pack version: GL_UNPACK_SWAP_BYTES has 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 a GL_RGB pixel are always stored with red first, green second, and blue third, regardless of the value of GL_UNPACK_SWAP_BYTES.
๐ฆ 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. This is relevant only for bitmap data. โจ
๐ฆ GL_UNPACK_ROW_LENGTH
If greater than 0, GL_UNPACK_ROW_LENGTH defines the number of pixels in a row. If the first pixel of a row is placed at location $p$ in memory, then the location of the first pixel of the next row is obtained by skipping
$k ~=~~ left { ~ lpile { n l above {a over s left ceiling { s n
l }
over a ^ right ceiling}} ~~ lpile {s ~>=~ a above 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 left ceiling { n l } over { 8 a } right ceiling$
components or indices.
The word component in this description refers to the nonindex values red, green, blue, alpha, and depth. Storage 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_HEIGHT defines 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 location $p$ in memory, then the location of the first pixel of the next row is obtained by skipping
$k ~=~~ left {~ lpile { n l h above {a over s left ceiling { s n
l h }
over a ^ right ceiling}} ~~ lpile {s ~ >=~ a above 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$).
Quick vocab check before we keep going, bestie: when this page says component, it means the nonindex values โ red, green, blue, alpha, and depth. So storage GL_RGB, for example, has three components per pixel: red first, then green, and finally blue last. iconic. ๐
GL_UNPACK_SKIP_PIXELS and GL_UNPACK_SKIP_ROWS are literally just convenience for the programmer โ they give you zero functionality that you couldnโt already duplicate by incrementing the pointer you pass to glDrawPixels, glTexImage1D, glTexImage2D, glTexSubImage1D, glTexSubImage2D, glBitmap, or glPolygonStipple. Setting GL_UNPACK_SKIP_PIXELS to i is equivalent to incrementing the pointer by i n components or indices, where n is the number of components or indices in each pixel. Setting GL_UNPACK_SKIP_ROWS to j is equivalent to incrementing the pointer by j k components or indices, where k is the number of components or indices per row, as just computed in the GL_UNPACK_ROW_LENGTH section. math girlie moment. ๐งฎโจ
GL_UNPACK_ALIGNMENT specifies the alignment requirements for the start of each pixel row in memory. The allowable values are 1 (byte-alignment), 2 (rows aligned to even-numbered bytes), 4 (word-alignment), and 8 (rows start on double-word boundaries). no cap. ๐
The following table gives the type, initial value, and range of valid values for each storage parameter that can be set with glPixelStore. Iโm giving it to you as a bullet list because tables are not the vibe here, but every single value is still exactly here:
GL_PACK_SWAP_BYTESโ typeboolean, initial valuefalse, valid rangetrue or false.GL_PACK_LSB_FIRSTโ typeboolean, initial valuefalse, valid rangetrue or false.GL_PACK_ROW_LENGTHโ typeinteger, initial value0, valid range[0,โ).GL_PACK_IMAGE_HEIGHTโ typeinteger, initial value0, valid range[0, โ).GL_PACK_SKIP_ROWSโ typeinteger, initial value0, valid range[0,โ).GL_PACK_SKIP_PIXELSโ typeinteger, initial value0, valid range[0,โ).GL_PACK_SKIP_IMAGESโ typeinteger, initial value0, valid range[0,โ).GL_PACK_ALIGNMENTโ typeinteger, initial value4, valid range1, 2, 4, or 8.
GL_UNPACK_SWAP_BYTESโ typeboolean, initial valuefalse, valid rangetrue or false.GL_UNPACK_LSB_FIRSTโ typeboolean, initial valuefalse, valid rangetrue or false.GL_UNPACK_ROW_LENGTHโ typeinteger, initial value0, valid range[0,โ).GL_UNPACK_IMAGE_HEIGHTโ typeinteger, initial value0, valid range[0,โ).GL_UNPACK_SKIP_ROWSโ typeinteger, initial value0, valid range[0,โ).GL_UNPACK_SKIP_PIXELSโ typeinteger, initial value0, valid range[0,โ).GL_UNPACK_SKIP_IMAGESโ typeinteger, initial value0, valid range[0,โ).GL_UNPACK_ALIGNMENTโ typeinteger, initial value4, valid range1, 2, 4, or 8.
glPixelStoref can be used to set any pixel store parameter. If the parameter type is boolean, then if param is 0, the parameter is false; otherwise it is set to true. If pname is an integer type parameter, param is rounded to the nearest integer. slay. ๐
Likewise, glPixelStorei can also be used to set any of the pixel store parameters. Boolean parameters are set to false if param is 0 and true otherwise. periodt.
๐ NOTES
The pixel storage modes in effect when glDrawPixels, glReadPixels, glTexImage1D, glTexImage2D, glTexImage3D, glTexSubImage1D, glTexSubImage2D, glTexSubImage3D, glBitmap, or glPolygonStipple is placed in a display list control the interpretation of memory data. Yes, bestie โ when itโs placed in the display list, not when the list runs. ๐ซถ
Likewise, if the GL_ARB_imaging extension is supported, the pixel storage modes in effect when glColorTable, glColorSubTable, glConvolutionFilter1D, glConvolutionFilter2D, of glSeparableFilter2D is placed in a display list control the interpretation of memory data.
The pixel storage modes in effect when a display list is executed are not significant. literally not the vibe. ๐
Pixel storage modes are client state and must be pushed and restored using glPushClientAttrib and glPopClientAttrib. donโt forget, bestie. ๐ฅ
๐ ERRORS
GL_INVALID_ENUMโ generated ifpnameis not an accepted value.GL_INVALID_VALUEโ 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.GL_INVALID_OPERATIONโ generated ifglPixelStoreis executed between the execution ofglBeginand the corresponding execution ofglEnd.
๐ ASSOCIATED GETS
glGetwith argumentGL_PACK_SWAP_BYTESglGetwith argumentGL_PACK_LSB_FIRSTglGetwith argumentGL_PACK_ROW_LENGTHglGetwith argumentGL_PACK_IMAGE_HEIGHTglGetwith argumentGL_PACK_SKIP_ROWSglGetwith argumentGL_PACK_SKIP_PIXELSglGetwith argumentGL_PACK_SKIP_IMAGESglGetwith argumentGL_PACK_ALIGNMENTglGetwith argumentGL_UNPACK_SWAP_BYTESglGetwith argumentGL_UNPACK_LSB_FIRSTglGetwith argumentGL_UNPACK_ROW_LENGTHglGetwith argumentGL_UNPACK_IMAGE_HEIGHTglGetwith argumentGL_UNPACK_SKIP_ROWSglGetwith argumentGL_UNPACK_SKIP_PIXELSglGetwith argumentGL_UNPACK_SKIP_IMAGESglGetwith argumentGL_UNPACK_ALIGNMENT
๐ SEE ALSO
glBitmap(3G)glColorTable(3G)glColorSubTable(3G)glConvolutionFilter1D(3G)glConvolutionFilter2D(3G)glSeparableFilter2D(3G)glDrawPixels(3G)glHistogram(3G)glMinmax(3G)glPixelMap(3G)glPixelTransfer(3G)glPixelZoom(3G)glPolygonStipple(3G)glPushClientAttrib(3G)glReadPixels(3G)glTexImage1D(3G)glTexImage2D(3G)glTexImage3D(3G)glTexSubImage1D(3G)glTexSubImage2D(3G)glTexSubImage3D(3G)
mwah ๐ โ source/version: GLPIXELSTORE(3G); date: the one chilling in the footer, bestie. periodt. ๐
๐ฆ where this page comes from
- opensuse-leap 16.0: Mesa-libGL-devel 24.1.7-160000.3.1 ยท MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 ยท MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 ยท MIT
- opensuse-leap 16.0: Mesa-libGL-devel 24.3.3-160000.3.1 ยท MIT
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms