GLCOPYPIXELS(3G) GLCOPYPIXELS(3G)
NAME
glCopyPixels - copy pixels in the frame buffer
C SPECIFICATION
void glCopyPixels( GLint x,
GLint y,
GLsizei width,
GLsizei height,
GLenum type )
PARAMETERS
x, y Specify the window coordinates of the lower left corner of the
rectangular region of pixels to be copied.
width, height
Specify the dimensions of the rectangular region of pixels to be
copied. Both must be nonnegative.
type Specifies whether color values, depth values, or stencil values
are to be copied. Symbolic constants GLCOLOR, GLDEPTH, and
GLSTENCIL are accepted.
DESCRIPTION
glCopyPixels copies a screen-aligned rectangle of pixels from the spec-
ified 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. width and height specify the dimen-
sions of the rectangular region to be copied. Both width and height
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:
glPixelTransfer, glPixelap, and glPixelZoom. This reference page
describes the effects on glCopyPixels of most, but not all, of the
parameters specified by these three commands.
glCopyPixels copies values from each pixel with the lower left-hand
corner at (x ] i, y ] j) for 0 <= i < width and 0 <= j < height. This
pixel is said to be the ith pixel in the jth row. Pixels are copied in
row order from the lowest to the highest row, left to right in each
row.
type specifies whether color, depth, or stencil data is to be copied.
The details of the transfer for each data type are as follows:
GLCOLOR Indices or RGBA colors are read from the buffer cur-
rently specified as the read source buffer (see
glReadBuffer). 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 GLINDEXSHIFT bits, and added to
GLINDEXOFSET. If GLINDEXSHIFT is negative, the
shift is to the right. In either case, zero bits fill
otherwise unspecified bit locations in the result. If
GLMAPCOLOR is true, the index is replaced with the
value that it references in lookup table
GLPIXELMAPITOI. Whether the lookup replacement of
the index is done or not, the integer part of the index
is then ANDed with (2^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 con-
verted to an internal floating-point with unspecified
precision. The conversion maps the largest repre-
sentable component value to 1.0, and component value 0
to 0.0. The resulting floating-point color values are
then multiplied by GLcSCALE and added to GLcBIAS,
where c is RED, GREN, BLUE, and ALPHA for the respec-
tive color components. The results are clamped to the
range [0,1]. If GLMAPCOLOR is true, each color compo-
nent is scaled by the size of lookup table
GLPIXELMAPcTOc, then replaced by the value that it
references in that table. c is R, G, B, or A.
If the GLARBimaging 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 col-
ors to fragments by attaching the current raster posi-
tion z coordinate and texture coordinates to each pixel,
then assigning window coordinates (xr ] i , yr ] j),
where (xr , yr) is the current raster position, and the
pixel was the ith pixel in the jth row. These pixel
fragments are then treated just like the fragments gen-
erated by rasterizing points, lines, or polygons. Tex-
ture mapping, fog, and all the fragment operations are
applied before the fragments are written to the frame
buffer.
GLDEPTH Depth values are read from the depth buffer and con-
verted directly to an internal floating-point with
unspecified precision. The resulting floating-point
depth value is then multiplied by GLDEPTHSCALE and
added to GLDEPTHBIAS. 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 (xr ] i , yr ] j),
where (xr , yr) is the current raster position, and the
pixel was the ith pixel in the jth row. These pixel
fragments are then treated just like the fragments gen-
erated by rasterizing points, lines, or polygons. Tex-
ture mapping, fog, and all the fragment operations are
applied before the fragments are written to the frame
buffer.
GLSTENCIL 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 GLINDEXSHIFT
bits, and added to GLINDEXOFSET. If GLINDEXSHIFT
is negative, the shift is to the right. In either case,
zero bits fill otherwise unspecified bit locations in
the result. If GLMAPSTENCIL is true, the index is
replaced with the value that it references in lookup ta-
ble GLPIXELMAPSTOS. Whether the lookup replacement
of the index is done or not, the integer part of the
index is then ANDed with (2^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 ith location of the jth row is
written to location (xr ] i , yr ] j), where (xr , yr)
is the current raster position. Only the pixel owner-
ship 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
glPixelZoom is used to change the x and y pixel zoom factors, pixels
are converted to fragments as follows. If (xr, yr) is the current
raster position, and a given pixel is in the ith location in the jth
row of the source pixel rectangle, then fragments are generated for
pixels whose centers are in the rectangle with corners at
(xr ] zoomx*i, yr ] zoomy*j)
and
(xr ] zoomx*(i]1), yr ] zoomy*(j]1))
where zoomx is the value of GLZOMX and zoomy is the value of
GLZOMY.
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, GLCOLOR);
NOTES
Modes specified by glPixelStore have no effect on the operation of
glCopyPixels.
ERORS
GLINVALIDENUM is generated if type is not an accepted value.
GLINVALIDVALUE is generated if either width or height is negative.
GLINVALIDOPERATION is generated if type is GLDEPTH and there is no
depth buffer.
GLINVALIDOPERATION is generated if type is GLSTENCIL and there is no
stencil buffer.
GLINVALIDOPERATION is generated if glCopyPixels is executed between
the execution of glBegin and the corresponding execution of glEnd.
ASOCIATED GETS
glGet with argument GLCURENTRASTERPOSITION
glGet with argument GLCURENTRASTERPOSITIONVALID
SEE ALSO
glColorTable, glConvolutionFilter1D, glConvolutionFilter2D,
glDepthFunc, glDrawBuffer, glDrawPixels, glatrixode, glPixelap,
glPixelTransfer, glPixelZoom, glRasterPos, glReadBuffer, glReadPixels,
glSeparableFilter2D, glStencilFunc
GLCOPYPIXELS(3G)
|