NAME

glCopyPixels - copy pixels in the frame buffer

C SPECIFICATION

void ggllCCooppyyPPiixxeellss( GLint _x,
                   GLint _y,
                   GLsizei _w_i_d_t_h,
                   GLsizei _h_e_i_g_h_t,
                   GLenum _t_y_p_e )

delim $$

PARAMETERS

_x, _y
Specify the window coordinates of the lower left corner of the rectangular region of pixels to be copied.
_w_i_d_t_h, _h_e_i_g_h_t
Specify the dimensions of the rectangular region of pixels to be copied. Both must be nonnegative.
_t_y_p_e
Specifies whether color values, depth values, or stencil values are to be copied. Symbolic constants GGLL__CCOOLLOORR, GGLL__DDEEPPTTHH, and GGLL__SSTTEENNCCIILL are accepted.

DESCRIPTION

ggllCCooppyyPPiixxeellss copies a screen-aligned rectangle of pixels from the specified frame buffer location to a region relative to the current raster position. Its operation is well defined only if the entire pixel source region is within the exposed portion of the window. Results of copies from outside the window, or from regions of the window that are not exposed, are hardware dependent and undefined.

_x and _y specify the window coordinates of the lower left corner of the rectangular region to be copied. _w_i_d_t_h and _h_e_i_g_h_t specify the dimensions of the rectangular region to be copied. Both _w_i_d_t_h and _h_e_i_g_h_t must not be negative.

Several parameters control the processing of the pixel data while it is being copied. These parameters are set with three commands: ggllPPiixxeellTTrraannssffeerr, ggllPPiixxeellMMaapp, and ggllPPiixxeellZZoooomm. This reference page describes the effects on ggllCCooppyyPPiixxeellss of most, but not all, of the parameters specified by these three commands.

ggllCCooppyyPPiixxeellss copies values from each pixel with the lower left-hand corner at (_x + $i$, _y + $j$) for 0 <= $i$ < _w_i_d_t_h and 0 <= $j$ < _h_e_i_g_h_t. This pixel is said to be the $i$th pixel in the $j$th row. Pixels are copied in row order from the lowest to the highest row, left to right in each row.

_t_y_p_e specifies whether color, depth, or stencil data is to be copied. The details of the transfer for each data type are as follows:

GGLL__CCOOLLOORR
Indices or RGBA colors are read from the buffer currently specified as the read source buffer (see ggllRReeaaddBBuuffffeerr). If the GL is in color index mode, each index that is read from this buffer is converted to a fixed-point with an unspecified number of bits to the right of the binary point. Each index is then shifted left by GGLL__IINNDDEEXX__SSHHIIFFTT bits, and added to GGLL__IINNDDEEXX__OOFFFFSSEETT. If GGLL__IINNDDEEXX__SSHHIIFFTT is negative, the shift is to the right. In either case, zero bits fill otherwise unspecified bit locations in the result. If GGLL__MMAAPP__CCOOLLOORR is true, the index is replaced with the value that it references in lookup table GGLL__PPIIXXEELL__MMAAPP__II__TTOO__II. Whether the lookup replacement of the index is done or not, the integer part of the index is then ANDed with $2 sup b -1$, where $b$ is the number of bits in a color index buffer.
If the GL is in RGBA mode,
the red, green, blue, and alpha components of each pixel that is read are converted to an internal floating-point with unspecified precision. The conversion maps the largest representable component value to 1.0, and component value 0 to 0.0. The resulting floating-point color values are then multiplied by GGLL__cc__SSCCAALLEE and added to GGLL__cc__BBIIAASS, where _c is RED, GREEN, BLUE, and ALPHA for the respective color components. The results are clamped to the range [0,1]. If GGLL__MMAAPP__CCOOLLOORR is true, each color component is scaled by the size of lookup table GGLL__PPIIXXEELL__MMAAPP__cc__TTOO__cc, then replaced by the value that it references in that table. _c is R, G, B, or A.
If the GGLL__AARRBB__iimmaaggiinngg extension is supported, the color values may
be additionally processed by color-table lookups, color-matrix transformations, and convolution filters.
The GL then converts the resulting indices or RGBA colors to fragments
by attaching the current raster position _z coordinate and texture coordinates to each pixel, then assigning window coordinates ($x sub r ~+~ i , y sub r ~+~ j$), where ($x sub r , y sub r$) is the current raster position, and the pixel was the $i$th pixel in the $j$th row. These pixel fragments are then treated just like the fragments generated by rasterizing points, lines, or polygons. Texture mapping, fog, and all the fragment operations are applied before the fragments are written to the frame buffer.
GGLL__DDEEPPTTHH
Depth values are read from the depth buffer and converted directly to an internal floating-point with unspecified precision. The resulting floating-point depth value is then multiplied by GGLL__DDEEPPTTHH__SSCCAALLEE and added to GGLL__DDEEPPTTHH__BBIIAASS. The result is clamped to the range [0,1].
The GL then converts the resulting depth components to fragments
by attaching the current raster position color or color index and texture coordinates to each pixel, then assigning window coordinates ($x sub r ~+~ i , y sub r ~+~ j$), where ($x sub r , y sub r$) is the current raster position, and the pixel was the $i$th pixel in the $j$th row. These pixel fragments are then treated just like the fragments generated by rasterizing points, lines, or polygons. Texture mapping, fog, and all the fragment operations are applied before the fragments are written to the frame buffer.
GGLL__SSTTEENNCCIILL
Stencil indices are read from the stencil buffer and converted to an internal fixed-point with an unspecified number of bits to the right of the binary point. Each fixed-point index is then shifted left by GGLL__IINNDDEEXX__SSHHIIFFTT bits, and added to GGLL__IINNDDEEXX__OOFFFFSSEETT. If GGLL__IINNDDEEXX__SSHHIIFFTT is negative, the shift is to the right. In either case, zero bits fill otherwise unspecified bit locations in the result. If GGLL__MMAAPP__SSTTEENNCCIILL is true, the index is replaced with the value that it references in lookup table GGLL__PPIIXXEELL__MMAAPP__SS__TTOO__SS. Whether the lookup replacement of the index is done or not, the integer part of the index is then ANDed with $2 sup b -1$, where $b$ is the number of bits in the stencil buffer. The resulting stencil indices are then written to the stencil buffer such that the index read from the $i$th location of the $j$th row is written to location ($x sub r ~+~ i , y sub r ~+~ j$), where ($x sub r , y sub r$) is the current raster position. Only the pixel ownership test, the scissor test, and the stencil writemask affect these write operations.

The rasterization described thus far assumes pixel zoom factors of 1.0. If
ggllPPiixxeellZZoooomm is used to change the $x$ and $y$ pixel zoom factors, pixels are converted to fragments as follows. If ($x sub r$, $y sub r$) is the current raster position, and a given pixel is in the $i$th location in the $j$th row of the source pixel rectangle, then fragments are generated for pixels whose centers are in the rectangle with corners at

($x sub r ~+~ zoom sub x^ i$, $y sub r ~+~ zoom sub y^j$)

and

($x sub r ~+~ zoom sub x^ (i ~+~ 1)$, $y sub r ~+~ zoom sub y^ ( j ~+~ 1 )$)

where $zoom sub x$ is the value of GGLL__ZZOOOOMM__XX and $zoom sub y$ is the value of GGLL__ZZOOOOMM__YY.

EXAMPLES

To copy the color pixel in the lower left corner of the window to the current raster position, use glCopyPixels(0, 0, 1, 1, GGLL__CCOOLLOORR);

NOTES

Modes specified by ggllPPiixxeellSSttoorree have no effect on the operation of ggllCCooppyyPPiixxeellss.

ERRORS

GGLL__IINNVVAALLIIDD__EENNUUMM is generated if _t_y_p_e is not an accepted value.

GGLL__IINNVVAALLIIDD__VVAALLUUEE is generated if either _w_i_d_t_h or _h_e_i_g_h_t is negative.

GGLL__IINNVVAALLIIDD__OOPPEERRAATTIIOONN is generated if _t_y_p_e is GGLL__DDEEPPTTHH and there is no depth buffer.

GGLL__IINNVVAALLIIDD__OOPPEERRAATTIIOONN is generated if _t_y_p_e is GGLL__SSTTEENNCCIILL and there is no stencil buffer.

GGLL__IINNVVAALLIIDD__OOPPEERRAATTIIOONN is generated if ggllCCooppyyPPiixxeellss is executed between the execution of ggllBBeeggiinn and the corresponding execution of ggllEEnndd.

ASSOCIATED GETS

ggllGGeett with argument GGLL__CCUURRRREENNTT__RRAASSTTEERR__PPOOSSIITTIIOONN
ggllGGeett with argument GGLL__CCUURRRREENNTT__RRAASSTTEERR__PPOOSSIITTIIOONN__VVAALLIIDD

SEE ALSO

ggllCCoolloorrTTaabbllee((33GG)), ggllCCoonnvvoolluuttiioonnFFiilltteerr11DD((33GG)), ggllCCoonnvvoolluuttiioonnFFiilltteerr22DD((33GG)), ggllDDeepptthhFFuunncc((33GG)), ggllDDrraawwBBuuffffeerr((33GG)), ggllDDrraawwPPiixxeellss((33GG)), ggllMMaattrriixxMMooddee((33GG)), ggllPPiixxeellMMaapp((33GG)), ggllPPiixxeellTTrraannssffeerr((33GG)), ggllPPiixxeellZZoooomm((33GG)), ggllRRaasstteerrPPooss((33GG)), ggllRReeaaddBBuuffffeerr((33GG)), ggllRReeaaddPPiixxeellss((33GG)), ggllSSeeppaarraabblleeFFiilltteerr22DD((33GG)), ggllSStteenncciillFFuunncc((33GG))