OpenGL C bindings library: libGL.a
void glPixelStoref(GLenum pName, GLfloat Parameter)
void glPixelStorei(GLenum pName, GLint Parameter)
pName | Specifies the symbolic name of the parameter to be set. The following values affect the packing of pixel data into memory: |
The following values affect the unpacking of pixel data from memory:
Parameter | Specifies the value to which pName is set. |
The glPixelStore subroutine sets pixel storage modes that affect the operation of subsequent glDrawPixels and glReadPixels subroutines as well as the unpacking of polygon stipple patterns (see the glPolygonStipple subroutine), bitmaps (see the glBitmap subroutine), and texture patterns (see the glTexImage1D subroutine, glTexImage2D subroutine, glTexImage3DEXT subroutine, glTexSubImage1D subroutine, glTexSubImage2D subroutine, and the glTexSubImage3DEXT subroutine).
The pName parameter is a symbolic constant indicating the parameter to be set, and the Parameter parameter is the new value. The following parameters affect how pixel data is returned to client memory, and are therefore significant only for glReadPixels commands. They are as follows:
The remaining parameters affect how pixel data is read from client memory. These values are significant for the glDrawPixels, glTexImage1D, glTexImage2D, glBitmap, and glPolygonStipple subroutines. They are as follows:
GL_UNPACK_SWAP_BYTES | If True, byte ordering for a multibyte color components, depth components, color indexes, or stencil indexes is reversed. That is, if a 4-byte component is made up 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 indexes. 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 significant for bitmap data only. |
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 the following:
where n is the number of components or indexes in a pixel, i is the number of pixels in a row (GL_UNPACK_ROW_LENGTH if it is greater than 0; otherwise, the width argument to the pixel routine), a is the value of GL_UNPACK_ALIGNMENT, and s is the size, in bytes, of a single component (if a < s, it is as if a = s). In the case of 1-bit values, the location of the next row is obtained by skipping the following: The word component in this description refers 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_EXT | If greater than 0 (zero), GL_UNPACK_IMAGE_HEIGHT_EXT defines the number of rows in a 3D image, otherwise the number of rows is defined to be the height of the 3D image. | |||
GL_UNPACK_SKIP_PIXELS, GL_UNPACK_SKIP_ROWS, and GL_UNPACK_SKIP_IMAGES_EXT | ||||
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 glDrawPixels,
glTexImage1D, glTexImage2D, glTexImage3DEXT, glBitmap, or glPolygonStipple. Setting GL_UNPACK_SKIP_PIXELS to i is equivalent to incrementing the pointer by in components or indexes, where n is the number of components or indexes in each pixel. Setting GL_UNPACK_SKIP_ROWS to j is equivalent to incrementing the pointer by jk components or indexes,
where k is the number of components or indexes per row, as computed in the GL_UNPACK_ROW_LENGTH section. Setting the GL_UNPACK_SKIP_IMAGES_EXT to l is equivalent to incrementing the pointer by lmk components or indexes, where m is the number of rows per image as specified by GL_UNPACK_IMAGE_HEIGHT.
|
The following table gives the type, initial value, and range of valid values for each of the storage parameters 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,+infinity) |
GL_PACK_IMAGE_HEIGTH_EXT | integer | 0 | [0,+infinity) |
GL_PACK_SKIP_ROWS | integer | 0 | [0,+infinity) |
GL_PACK_SKIP_PIXELS | integer | 0 | [0,+infinity) |
GL_PACK_SKIP_IMAGES_EXT | integer | 0 | [0,+infinity) |
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,+infinity) |
GL_UNPACK_IMAGE_HEIGTH_EXT | integer | 0 | [0,+infinity) |
GL_UNPACK_SKIP_ROWS | integer | 0 | [0,+infinity) |
GL_UNPACK_SKIP_PIXELS | integer | 0 | [0,+infinity) |
GL_UNPACK_SKIP_IMAGES_EXT | integer | 0 | [0,+infinity) |
GL_UNPACK_ALIGNMENT | integer | 4 | 1, 2, 4, or 8 |
The glPixelStoref subroutine can be used to set any pixel store parameter. If the parameter type is Boolean, and if Parameter is 0.0, the parameter is False; otherwise it is set to True. If pName is an integer type parameter, Parameter 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 Parameter is 0 and True otherwise. Parameter is converted to floating-point format before being assigned to real-valued parameters.
The pixel storage modes in effect when glDrawPixels, glReadPixels, glTexImage, glBitmap, or glPolygonStipple 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.
GL_INVALID_ENUM | pName is not an accepted value. |
GL_INVALID_VALUE | A negative row length, pixel skip, or row skip value is specified, or alignment is specified as other than 1, 2, 4, or 8. |
Associated gets for the glPixelStore subroutine are as follows. (See the glGet subroutine for more information.)
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_HEIGTH_EXT
glGet with argument GL_PACK_SKIP_ROWS
glGet with argument GL_PACK_SKIP_PIXELS
glGet with argument GL_PACK_SKIP_IMAGES_EXT
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_HEIGTH_EXT
glGet with argument GL_UNPACK_SKIP_ROWS
glGet with argument GL_UNPACK_SKIP_PIXELS
glGet with argument GL_UNPACK_SKIP_IMAGES_EXT
glGet with argument GL_UNPACK_ALIGNMENT.
GL_INVALID_OPERATION | The glPixelStore subroutine is called between a call to glBegin and the corresponding call to glEnd. |
/usr/include/GL/gl.h | Contains C language constants, variable type definitions, and ANSI function prototypes for OpenGL. |
The glBegin or glEnd subroutine, glBitmap subroutine, glDrawPixels subroutine, glPixelMap subroutine, glPixelTransfer subroutine, glPixelZoom subroutine, glPolygonStipple subroutine, glReadPixels subroutine, glTexImage1D subroutine, glTexImage2D subroutine, glTexImage3DEXT subroutine, glTexSubImage1D subroutine, glTexSubImage2D subroutine, glTexSubImage3DEXT subroutine.