GLPIXELSTORE(3gl)GLPIXELSTORE(3gl)NAME
glPixelStoref, glPixelStorei - set pixel storage modes
C SPECIFICATION
void glPixelStoref( GLenum pname,
GLfloat param )
void glPixelStorei( GLenum pname,
GLint param )
PARAMETERS
pname Specifies the symbolic name of the parameter to be set. Six
values affect the packing of pixel data into memory:
GL_PACK_SWAP_BYTES, GL_PACK_LSB_FIRST, GL_PACK_ROW_LENGTH,
GL_PACK_SKIP_PIXELS, GL_PACK_SKIP_ROWS, and GL_PACK_ALIGNMENT.
Seven more affect the unpacking of pixel data from memory:
GL_UNPACK_SWAP_BYTES, GL_UNPACK_LSB_FIRST, GL_UNPACK_ROW_LENGTH,
GL_UNPACK_SKIP_PIXELS, GL_UNPACK_SKIP_ROWS, GL_UNPACK_ALIGNMENT
and GL_UNPACK_CONSTANT_DATA_SUNX.
param Specifies the value that pname is set to.
DESCRIPTION
glPixelStore sets pixel storage modes that affect the operation of sub‐
sequent glDrawPixels and glReadPixels as well as the unpacking of poly‐
gon stipple patterns (see glPolygonStipple), bitmaps (see glBitmap),
and texture patterns (see glTexImage1D, glTexImage2D, glTexSubImage1D,
and glTexSubImage2D).
pname is a symbolic constant indicating the parameter to be set, and
param is the new value. Six of the thirteen storage parameters affect
how pixel data is returned to client memory, and are therefore signifi‐
cant only for glReadPixels commands. 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 b0, b1,
b2, b3, it is stored in memory as b3, b2, b1, b0 if
GL_PACK_SWAP_BYTES is true. 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 format pixel are always
stored with red first, green second, and blue third, regard‐
less of the value of GL_PACK_SWAP_BYTES.
GL_PACK_LSB_FIRST
If true, bits are ordered within a byte from least signifi‐
cant to most significant; otherwise, the first bit in each
byte is the most significant one. This parameter is signifi‐
cant 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
nl s≥a
k=⎩
_⎡___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 argu‐
ment 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=8a⎡__⎤
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_PACK_SKIP_PIXELS and GL_PACK_SKIP_ROWS
These values are provided as a convenience to the programmer;
they provide no functionality that cannot be duplicated sim‐
ply by incrementing the pointer passed to glReadPixels. Set‐
ting GL_PACK_SKIP_PIXELS to i is equivalent to incrementing
the pointer by in components or indices, where n is the num‐
ber of components or indices in each pixel. Setting
GL_PACK_SKIP_ROWS to j is equivalent to incrementing the
pointer by jk components or indices, where k is the number of
components or indices per row, as just computed in the
GL_PACK_ROW_LENGTH section.
GL_PACK_ALIGNMENT
Specifies the alignment requirements for the start of each
pixel row in memory. The allowable values are 1 (byte-align‐
ment), 2 (rows aligned to even-numbered bytes), 4 (word-
alignment), and 8 (rows start on double-word boundaries).
The other seven of the thirteen storage parameters affect how pixel
data is read from client memory. These values are significant for
glDrawPixels, glTexImage1D, glTexImage2D, glTexSubImage1D, glTexSubIm‐
age2D, glBitmap, and glPolygonStipple. 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 b0, b1, b2, b3,
it is taken from memory as b3, b2, b1, b0 if
GL_UNPACK_SWAP_BYTES is true. 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 format 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 loca‐
tion p in memory, then the location of the first pixel of the
next row is obtained by skipping
k=⎩
_⎡___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 argu‐
ment 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=8a⎡__⎤
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_SKIP_PIXELS and GL_UNPACK_SKIP_ROWS
These values are provided as a convenience to the programmer;
they provide no functionality that cannot be duplicated by
incrementing the pointer passed to glDrawPixels, glTexImage1D,
glTexImage2D, glTexSubImage1D, glTexSubImage2D, glBitmap, or
glPolygonStipple. Setting GL_UNPACK_SKIP_PIXELS to i is equiva‐
lent to incrementing the pointer by in 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 jk components or indices, where k is the number
of components or indices per row, as just computed in the
GL_UNPACK_ROW_LENGTH section.
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).
GL_UNPACK_CONSTANT_DATA_SUNX
If true, application specified data pointer may be used as-is by
the library without making a second copy internally. This
implies that the application cannot change this data pointer
once it has been sent down to the library. Whether the applica‐
tion specified constant data is used as-is internally is imple‐
mentation dependent. An implementation may still make a second
copy even when this value is set to GL_TRUE.
The following table gives the type, initial value, and range of valid
values for each storage parameter that can be set with glPixelStore.
┌─────────────────────────────┬─────────┬───────────────┬───────────────┐
│ pname │ type │ initial value │ valid range │
├─────────────────────────────┼─────────┼───────────────┼───────────────┤
│ GL_PACK_SWAP_BYTES │ boolean │ false │ true or false │
│ GL_PACK_LSB_FIRST │ boolean │ false │ true or false │
│ GL_PACK_ROW_LENGTH │ integer │ 0 │ [0,∞) │
│ GL_PACK_SKIP_ROWS │ integer │ 0 │ [0,∞) │
│ GL_PACK_SKIP_PIXELS │ integer │ 0 │ [0,∞) │
│ GL_PACK_ALIGNMENT │ integer │ 4 │ 1, 2, 4, or 8 │
├─────────────────────────────┼─────────┼───────────────┼───────────────┤
│ GL_UNPACK_SWAP_BYTES │ boolean │ false │ true or false │
│ GL_UNPACK_LSB_FIRST │ boolean │ false │ true or false │
│ GL_UNPACK_ROW_LENGTH │ integer │ 0 │ [0,∞) │
│ GL_UNPACK_SKIP_ROWS │ integer │ 0 │ [0,∞) │
│ GL_UNPACK_SKIP_PIXELS │ integer │ 0 │ [0,∞) │
│ GL_UNPACK_ALIGNMENT │ integer │ 4 │ 1, 2, 4, or 8 │
│GL_UNPACK_CONSTANT_DATA_SUNX │ boolean │ false │ true or false │
└─────────────────────────────┴─────────┴───────────────┴───────────────┘
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 a integer type parameter,
param is rounded to the nearest integer.
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.
NOTES
The pixel storage modes in effect when glDrawPixels, glReadPixels,
glTexImage1D, glTexImage2D, glTexSubImage1D, glTexSubImage2D, glBitmap,
or glPolygonStipple is placed in a display list control the interpreta‐
tion of memory data. The pixel storage modes in effect when a display
list is executed are not significant. At this time, if GL_UNPACK_CON‐
STANT_DATA_SUNX is True and all other pixel store modes are default,
then the application specified data pointer is used internally. In this
case, this constant data pointer should remain unchanged for the life‐
time of the display list. Changing the data pointer after it has been
defined as "constant" during display list compilation will result in
unpredictable results.
Pixel storage modes are client state and must be pushed and restored
using glPushClientAttrib and glPopClientAttrib.
The extension GL_SUNX_CONSTANT_DATA should be defined in order to use
GL_UNPACK_CONSTANT_DATA_SUNX.
If GL_UNPACK_CONSTANT_DATA_SUNX is True, but some of the other pixel
store values for unpacking the pixels is non-default, then the
GL_UNPACK_CONSTANT_DATA_SUNX value is ignored.
ERRORS
GL_INVALID_ENUM is generated if pname is not an accepted value.
GL_INVALID_VALUE is generated if a negative row length, pixel skip, or
row skip value is specified, or if alignment is specified as other than
1, 2, 4, or 8.
GL_INVALID_OPERATION is generated if glPixelStore is executed between
the execution of glBegin and the corresponding execution of glEnd.
ASSOCIATED GETS
glGet with argument GL_PACK_SWAP_BYTES
glGet with argument GL_PACK_LSB_FIRST
glGet with argument GL_PACK_ROW_LENGTH
glGet with argument GL_PACK_SKIP_ROWS
glGet with argument GL_PACK_SKIP_PIXELS
glGet with argument GL_PACK_ALIGNMENT
glGet with argument GL_UNPACK_SWAP_BYTES
glGet with argument GL_UNPACK_LSB_FIRST
glGet with argument GL_UNPACK_ROW_LENGTH
glGet with argument GL_UNPACK_SKIP_ROWS
glGet with argument GL_UNPACK_SKIP_PIXELS
glGet with argument GL_UNPACK_ALIGNMENT
glGet with argument GL_UNPACK_CONSTANT_DATA_SUNX
SEE ALSO
glBitmap, glDrawPixels, glPixelMap, glPixelTransfer, glPixelZoom,
glPolygonStipple, glPushClientAttrib, glReadPixels, glTexImage1D,
glTexImage2D, glTexSubImage1D, glTexSubImage2D
15 Mar 97 GLPIXELSTORE(3gl)