GLPIXELSTORE(3G) | GLPIXELSTORE(3G) |
glPixelStoref, glPixelStorei - set pixel storage modes
void glPixelStoref( GLenum pname,
GLfloat param )
void glPixelStorei( GLenum pname,
GLint param )
glPixelStore sets pixel storage modes that affect the operation of subsequent glDrawPixels and glReadPixels as well as the unpacking of polygon stipple patterns (see glPolygonStipple), bitmaps (see glBitmap), texture patterns (see glTexImage1D, glTexImage2D, glTexImage3D, glTexSubImage1D, glTexSubImage2D, glTexSubImage3D). 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.
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:
k = nl for s>=a, (a/s)(snl/a) for 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 = 8a (nl/8a)
components or indices.
k = nlh for s>=a, (a/s)(snlh/a) for 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
arguemnt 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 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:
k = nl for s>=a, (a/s)(snl/a) for 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 = 8a (nl/8a)
components or indices.
k = nlh for s>=a, (a/s)(snlh/a) for 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 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 Valid
Value 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,inf]
GL_PACK_IMAGE_HEIGHT integer 0 [0,inf]
GL_PACK_SKIP_ROWS integer 0 [0,inf]
GL_PACK_SKIP_PIXELS integer 0 [0,inf]
GL_PACK_SKIP_IMAGES integer 0 [0,inf]
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,inf]
GL_UNPACK_IMAGE_HEIGHT integer 0 [0,inf]
GL_UNPACK_SKIP_ROWS integer 0 [0,inf]
GL_UNPACK_SKIP_PIXELS integer 0 [0,inf]
GL_UNPACK_SKIP_IMAGES integer 0 [0,inf]
GL_UNPACK_ALIGNMENT integer 4 1, 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 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.
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. 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 intrepretation of memory data. The pixel storage modes in effect when a display list is executed are not significant.
Pixel storage modes are client state and must be pushed and
restored using
glPushClientAttrib and glPopClientAttrib.
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.
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_IMAGE_HEIGHT
glGet with argument GL_PACK_SKIP_ROWS
glGet with argument GL_PACK_SKIP_PIXELS
glGet with argument GL_PACK_SKIP_IMAGES
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_IMAGE_HEIGHT
glGet with argument GL_UNPACK_SKIP_ROWS
glGet with argument GL_UNPACK_SKIP_PIXELS
glGet with argument GL_UNPACK_SKIP_IMAGES
glGet with argument GL_UNPACK_ALIGNMENT
glBitmap, glColorTable, glColorSubTable, glConvolutionFilter1D, glConvolutionFilter2D, glSeparableFilter2D, glDrawPixels, glHistogram, glMinmax, glPixelMap, glPixelTransfer, glPixelZoom, glPolygonStipple, glPushClientAttrib, glReadPixels, glTexImage1D, glTexImage2D, glTexImage3D, glTexSubImage1D, glTexSubImage2D, glTexSubImage3D