The glPixelStoref and glPixelStorei functions set pixel storage modes.
void glPixelStoref(
GLenum pname,
GLfloat param
);
void glPixelStorei(
GLenum pname,
GLint param
);
components or indexes, where n is the number of components or indexes in a pixel, l is the number of pixels in a row (GL_PACK_ROW_LENGTH if it is greater than zero, 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
components or indexes.
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.
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, glBitmap, and glPolygonStipple. They are as follows:
components or indexes, where n is the number of components or indexes in a pixel, l is the number of pixels in a row (GL_UNPACK_ROW_LENGTH if it is greater than zero, 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
components or indexes.
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.
The glPixelStore function 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), and texture patterns (see glTexImage1D and glTexImage2D).
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_SWAP_BYTES | 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 |
The glPixelStoref function can be used to set any pixel store parameter. If the parameter type is Boolean, and if param is 0.0, then the parameter is false; otherwise it is set to true. If pname is an integer type parameter, then param is rounded to the nearest integer.
Likewise, the glPixelStorei function 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 param parameter is converted to floating point before being assigned to real-valued parameters.
The pixel storage modes in effect when glDrawPixels, glReadPixels, glTexImage1D, glTexImage2D, 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.
The following functions retrieve information related to glPixelStore:
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
The following are the error codes generated and their conditions.
Error Code | Condition |
---|---|
GL_INVALID_ENUM | pname was not an accepted value. |
GL_INVALID_VALUE | A negative row length, pixel skip, or row skip value was specified, or if alignment was specified as other than 1, 2, 4, or 8. |
GL_INVALID_OPERATION | glPixelStore was called between a call to glBegin and the corresponding call to glEnd. |
Windows NT: Use version 3.5 and later.
Windows: Use Windows 95 and later.
Windows CE: Unsupported.
Header: Declared in gl.h.
Import Library: Link with opengl32.lib.
glBegin, glBitmap, glDrawPixels, glEnd, glPixelMap, glPixelTransfer, glPixelZoom, glPolygonStipple, glReadPixels, glTexImage1D, glTexImage2D