table of contents
GLCOPYPIXELS(3G) | OpenGL Manual | 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
width, height
type
DESCRIPTION¶
glCopyPixels 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. width and height specify the dimensions 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(), glPixelMap(), 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:
GL_COLOR
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 format 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 GL_c_SCALE and added to GL_c_BIAS, where c is RED, GREEN, BLUE, and ALPHA for the respective color components. The results are clamped to the range [0,1]. If GL_MAP_COLOR is true, each color component is scaled by the size of lookup table GL_PIXEL_MAP_c_TO_c, then replaced by the value that it references in that table. c is R, G, B, or A.
If the ARB_imaging 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 r + i y r + j, where x r y r 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 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.
GL_DEPTH
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 r + i y r + j, where x r y r 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 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.
GL_STENCIL
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 x r y r 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
x r + zoom x i y r + zoom y j
and
x r + zoom x i + 1 y r + zoom y j + 1
where zoom x is the value of GL_ZOOM_X and zoom y is the value of GL_ZOOM_Y.
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, GL_COLOR);
NOTES¶
Modes specified by glPixelStore() have no effect on the operation of glCopyPixels.
ERRORS¶
GL_INVALID_ENUM is generated if type is not an accepted value.
GL_INVALID_VALUE is generated if either width or height is negative.
GL_INVALID_OPERATION is generated if type is GL_DEPTH and there is no depth buffer.
GL_INVALID_OPERATION is generated if type is GL_STENCIL and there is no stencil buffer.
GL_INVALID_OPERATION is generated if glCopyPixels is executed between the execution of glBegin() and the corresponding execution of glEnd().
ASSOCIATED GETS¶
glGet() with argument GL_CURRENT_RASTER_POSITION
glGet() with argument GL_CURRENT_RASTER_POSITION_VALID
SEE ALSO¶
glColorTable(), glConvolutionFilter1D(), glConvolutionFilter2D(), glDepthFunc(), glDrawBuffer(), glDrawPixels(), glMatrixMode(), glPixelMap(), glPixelTransfer(), glPixelZoom(), glRasterPos(), glReadBuffer(), glReadPixels(), glSeparableFilter2D(), glStencilFunc(), glWindowPos()
COPYRIGHT¶
Copyright © 1991-2006 Silicon Graphics, Inc. This document is licensed under the SGI Free Software B License. For details, see http://oss.sgi.com/projects/FreeB/.
AUTHORS¶
opengl.org
04/12/2021 | opengl.org |