1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <!DOCTYPE book PUBLIC
"-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
3 "http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
4 <refentry id=
"glCopyPixels">
9 <holder>Silicon Graphics, Inc.
</holder>
12 <refentrytitle>glCopyPixels
</refentrytitle>
13 <manvolnum>3G
</manvolnum>
16 <refname>glCopyPixels
</refname>
17 <refpurpose>copy pixels in the frame buffer
</refpurpose>
19 <refsynopsisdiv><title>C Specification
</title>
22 <funcdef>void
<function>glCopyPixels
</function></funcdef>
23 <paramdef>GLint
<parameter>x
</parameter></paramdef>
24 <paramdef>GLint
<parameter>y
</parameter></paramdef>
25 <paramdef>GLsizei
<parameter>width
</parameter></paramdef>
26 <paramdef>GLsizei
<parameter>height
</parameter></paramdef>
27 <paramdef>GLenum
<parameter>type
</parameter></paramdef>
31 <!-- eqn: ignoring delim $$ -->
32 <refsect1 id=
"parameters"><title>Parameters
</title>
35 <term><parameter>x
</parameter></term>
36 <term><parameter>y
</parameter></term>
39 Specify the window coordinates of the lower left corner
40 of the rectangular region of pixels to be copied.
45 <term><parameter>width
</parameter></term>
46 <term><parameter>height
</parameter></term>
49 Specify the dimensions of the rectangular region of pixels to be copied.
50 Both must be nonnegative.
55 <term><parameter>type
</parameter></term>
58 Specifies whether color values,
60 or stencil values are to be copied.
62 <constant>GL_COLOR
</constant>,
63 <constant>GL_DEPTH
</constant>,
64 and
<constant>GL_STENCIL
</constant> are accepted.
70 <refsect1 id=
"description"><title>Description
</title>
72 <function>glCopyPixels
</function> copies a screen-aligned rectangle of pixels
73 from the specified frame buffer location to a region relative to the
74 current raster position.
75 Its operation is well defined only if the entire pixel source region
76 is within the exposed portion of the window.
77 Results of copies from outside the window,
78 or from regions of the window that are not exposed,
79 are hardware dependent and undefined.
82 <parameter>x
</parameter> and
<parameter>y
</parameter> specify the window coordinates of
83 the lower left corner of the rectangular region to be copied.
84 <parameter>width
</parameter> and
<parameter>height
</parameter> specify the dimensions of the
85 rectangular region to be copied.
86 Both
<parameter>width
</parameter> and
<parameter>height
</parameter> must not be negative.
89 Several parameters control the processing of the pixel data
90 while it is being copied.
91 These parameters are set with three commands:
92 <citerefentry><refentrytitle>glPixelTransfer
</refentrytitle></citerefentry>,
93 <citerefentry><refentrytitle>glPixelMap
</refentrytitle></citerefentry>, and
94 <citerefentry><refentrytitle>glPixelZoom
</refentrytitle></citerefentry>.
95 This reference page describes the effects on
<function>glCopyPixels
</function> of most,
96 but not all, of the parameters specified by these three commands.
99 <function>glCopyPixels
</function> copies values from each pixel with the lower left-hand corner at
100 <inlineequation><mml:math>
101 <!-- eqn: (x + i, y + j):-->
102 <mml:mfenced open=
"(" close=
")">
104 <mml:mi mathvariant=
"italic">x
</mml:mi>
106 <mml:mi mathvariant=
"italic">i
</mml:mi>
109 <mml:mi mathvariant=
"italic">y
</mml:mi>
111 <mml:mi mathvariant=
"italic">j
</mml:mi>
114 </mml:math></inlineequation>
116 <inlineequation><mml:math>
117 <!-- eqn: 0 <= i < width:-->
120 <mml:mo><=
</mml:mo>
121 <mml:mi mathvariant=
"italic">i
</mml:mi>
122 <mml:mo><</mml:mo>
123 <mml:mi mathvariant=
"italic">width
</mml:mi>
125 </mml:math></inlineequation>
127 <inlineequation><mml:math>
128 <!-- eqn: 0 <= j < height:-->
131 <mml:mo><=
</mml:mo>
132 <mml:mi mathvariant=
"italic">j
</mml:mi>
133 <mml:mo><</mml:mo>
134 <mml:mi mathvariant=
"italic">height
</mml:mi>
136 </mml:math></inlineequation>.
137 This pixel is said to be the
138 <inlineequation><mml:math><mml:mi mathvariant=
"italic">i
</mml:mi></mml:math></inlineequation>th
140 <inlineequation><mml:math><mml:mi mathvariant=
"italic">j
</mml:mi></mml:math></inlineequation>th
142 Pixels are copied in row order from the lowest to the highest row,
143 left to right in each row.
146 <parameter>type
</parameter> specifies whether color, depth, or stencil data is to be copied.
147 The details of the transfer for each data type are as follows:
151 <term><constant>GL_COLOR
</constant></term>
154 Indices or RGBA colors are read from the buffer currently specified as the
155 read source buffer (see
<citerefentry><refentrytitle>glReadBuffer
</refentrytitle></citerefentry>).
156 If the GL is in color index mode,
157 each index that is read from this buffer is converted
158 to a fixed-point format with an unspecified
159 number of bits to the right of the binary point.
160 Each index is then shifted left by
<constant>GL_INDEX_SHIFT
</constant> bits,
161 and added to
<constant>GL_INDEX_OFFSET
</constant>.
162 If
<constant>GL_INDEX_SHIFT
</constant> is negative,
163 the shift is to the right.
164 In either case, zero bits fill otherwise unspecified bit locations in the
166 If
<constant>GL_MAP_COLOR
</constant> is true,
167 the index is replaced with the value that it references in lookup table
168 <constant>GL_PIXEL_MAP_I_TO_I
</constant>.
169 Whether the lookup replacement of the index is done or not,
170 the integer part of the index is then ANDed with
171 <inlineequation><mml:math>
172 <!-- eqn: 2 sup b -1:-->
174 <mml:msup><mml:mn>2</mml:mn>
175 <mml:mi mathvariant=
"italic">b
</mml:mi>
180 </mml:math></inlineequation>,
182 <inlineequation><mml:math><mml:mi mathvariant=
"italic">b
</mml:mi></mml:math></inlineequation>
183 is the number of bits in a color index buffer.
186 If the GL is in RGBA mode,
187 the red, green, blue, and alpha components of each pixel that is read
188 are converted to an internal floating-point format with unspecified
190 The conversion maps the largest representable component value to
1.0,
191 and component value
0 to
0.0.
192 The resulting floating-point color values are then multiplied
193 by
<constant>GL_c_SCALE
</constant> and added to
<constant>GL_c_BIAS
</constant>,
194 where
<emphasis>c
</emphasis> is RED, GREEN, BLUE, and ALPHA
195 for the respective color components.
196 The results are clamped to the range [
0,
1].
197 If
<constant>GL_MAP_COLOR
</constant> is true,
198 each color component is scaled by the size of lookup table
199 <constant>GL_PIXEL_MAP_c_TO_c
</constant>,
200 then replaced by the value that it references in that table.
201 <emphasis>c
</emphasis> is R, G, B, or A.
204 If the
<code>ARB_imaging
</code> extension is supported, the color values may
206 additionally processed by color-table lookups, color-matrix
207 transformations, and convolution filters.
210 The GL then converts the resulting indices or RGBA colors to fragments
211 by attaching the current raster position
<emphasis>z
</emphasis> coordinate and
212 texture coordinates to each pixel,
213 then assigning window coordinates
214 <inlineequation><mml:math>
215 <!-- eqn: (x sub r + i , y sub r + j):-->
216 <mml:mfenced open=
"(" close=
")">
218 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
219 <mml:mi mathvariant=
"italic">r
</mml:mi>
222 <mml:mi mathvariant=
"italic">i
</mml:mi>
225 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
226 <mml:mi mathvariant=
"italic">r
</mml:mi>
229 <mml:mi mathvariant=
"italic">j
</mml:mi>
232 </mml:math></inlineequation>,
234 <inlineequation><mml:math>
235 <!-- eqn: (x sub r , y sub r):-->
236 <mml:mfenced open=
"(" close=
")">
237 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
238 <mml:mi mathvariant=
"italic">r
</mml:mi>
240 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
241 <mml:mi mathvariant=
"italic">r
</mml:mi>
244 </mml:math></inlineequation>
245 is the current raster position,
246 and the pixel was the
247 <inlineequation><mml:math><mml:mi mathvariant=
"italic">i
</mml:mi></mml:math></inlineequation>th
249 <inlineequation><mml:math><mml:mi mathvariant=
"italic">j
</mml:mi></mml:math></inlineequation>th
251 These pixel fragments are then treated just like the fragments generated by
252 rasterizing points, lines, or polygons.
255 and all the fragment operations are applied before the fragments are written
261 <term><constant>GL_DEPTH
</constant></term>
264 Depth values are read from the depth buffer and
265 converted directly to an internal floating-point format
266 with unspecified precision.
267 The resulting floating-point depth value is then multiplied
268 by
<constant>GL_DEPTH_SCALE
</constant> and added to
<constant>GL_DEPTH_BIAS
</constant>.
269 The result is clamped to the range [
0,
1].
272 The GL then converts the resulting depth components to fragments
273 by attaching the current raster position color or color index and
274 texture coordinates to each pixel,
275 then assigning window coordinates
276 <inlineequation><mml:math>
277 <!-- eqn: (x sub r + i , y sub r + j):-->
278 <mml:mfenced open=
"(" close=
")">
280 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
281 <mml:mi mathvariant=
"italic">r
</mml:mi>
284 <mml:mi mathvariant=
"italic">i
</mml:mi>
287 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
288 <mml:mi mathvariant=
"italic">r
</mml:mi>
291 <mml:mi mathvariant=
"italic">j
</mml:mi>
294 </mml:math></inlineequation>,
296 <inlineequation><mml:math>
297 <!-- eqn: (x sub r , y sub r):-->
298 <mml:mfenced open=
"(" close=
")">
299 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
300 <mml:mi mathvariant=
"italic">r
</mml:mi>
302 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
303 <mml:mi mathvariant=
"italic">r
</mml:mi>
306 </mml:math></inlineequation>
307 is the current raster position,
308 and the pixel was the
309 <inlineequation><mml:math><mml:mi mathvariant=
"italic">i
</mml:mi></mml:math></inlineequation>th
311 <inlineequation><mml:math><mml:mi mathvariant=
"italic">j
</mml:mi></mml:math></inlineequation>th
313 These pixel fragments are then treated just like the fragments generated by
314 rasterizing points, lines, or polygons.
317 and all the fragment operations are applied before the fragments are written
323 <term><constant>GL_STENCIL
</constant></term>
326 Stencil indices are read from the stencil buffer and
327 converted to an internal fixed-point format
328 with an unspecified number of bits to the right of the binary point.
329 Each fixed-point index is then shifted left by
<constant>GL_INDEX_SHIFT
</constant> bits,
330 and added to
<constant>GL_INDEX_OFFSET
</constant>.
331 If
<constant>GL_INDEX_SHIFT
</constant> is negative,
332 the shift is to the right.
333 In either case, zero bits fill otherwise unspecified bit locations in the
335 If
<constant>GL_MAP_STENCIL
</constant> is true,
336 the index is replaced with the value that it references in lookup table
337 <constant>GL_PIXEL_MAP_S_TO_S
</constant>.
338 Whether the lookup replacement of the index is done or not,
339 the integer part of the index is then ANDed with
340 <inlineequation><mml:math>
341 <!-- eqn: 2 sup b -1:-->
343 <mml:msup><mml:mn>2</mml:mn>
344 <mml:mi mathvariant=
"italic">b
</mml:mi>
349 </mml:math></inlineequation>,
351 <inlineequation><mml:math><mml:mi mathvariant=
"italic">b
</mml:mi></mml:math></inlineequation>
352 is the number of bits in the stencil buffer.
353 The resulting stencil indices are then written to the stencil buffer
354 such that the index read from the
355 <inlineequation><mml:math><mml:mi mathvariant=
"italic">i
</mml:mi></mml:math></inlineequation>th
357 <inlineequation><mml:math><mml:mi mathvariant=
"italic">j
</mml:mi></mml:math></inlineequation>th
359 is written to location
360 <inlineequation><mml:math>
361 <!-- eqn: (x sub r + i , y sub r + j):-->
362 <mml:mfenced open=
"(" close=
")">
364 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
365 <mml:mi mathvariant=
"italic">r
</mml:mi>
368 <mml:mi mathvariant=
"italic">i
</mml:mi>
371 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
372 <mml:mi mathvariant=
"italic">r
</mml:mi>
375 <mml:mi mathvariant=
"italic">j
</mml:mi>
378 </mml:math></inlineequation>,
380 <inlineequation><mml:math>
381 <!-- eqn: (x sub r , y sub r):-->
382 <mml:mfenced open=
"(" close=
")">
383 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
384 <mml:mi mathvariant=
"italic">r
</mml:mi>
386 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
387 <mml:mi mathvariant=
"italic">r
</mml:mi>
390 </mml:math></inlineequation>
391 is the current raster position.
392 Only the pixel ownership test,
394 and the stencil writemask affect these write operations.
400 The rasterization described thus far assumes pixel zoom factors of
1.0.
402 <citerefentry><refentrytitle>glPixelZoom
</refentrytitle></citerefentry> is used to change the
403 <inlineequation><mml:math><mml:mi mathvariant=
"italic">x
</mml:mi></mml:math></inlineequation>
405 <inlineequation><mml:math><mml:mi mathvariant=
"italic">y
</mml:mi></mml:math></inlineequation>
407 pixels are converted to fragments as follows.
409 <inlineequation><mml:math>
410 <!-- eqn: (x sub r, y sub r):-->
411 <mml:mfenced open=
"(" close=
")">
412 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
413 <mml:mi mathvariant=
"italic">r
</mml:mi>
415 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
416 <mml:mi mathvariant=
"italic">r
</mml:mi>
419 </mml:math></inlineequation>
420 is the current raster position,
421 and a given pixel is in the
422 <inlineequation><mml:math><mml:mi mathvariant=
"italic">i
</mml:mi></mml:math></inlineequation>th
424 <inlineequation><mml:math><mml:mi mathvariant=
"italic">j
</mml:mi></mml:math></inlineequation>th
427 then fragments are generated for pixels whose centers are in the rectangle
431 <inlineequation><mml:math>
432 <!-- eqn: (x sub r + {zoom sub x} i, y sub r + {zoom sub y} j):-->
433 <mml:mfenced open=
"(" close=
")">
435 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
436 <mml:mi mathvariant=
"italic">r
</mml:mi>
439 <mml:mfenced open=
"" close=
"">
440 <mml:msub><mml:mi mathvariant=
"italic">zoom
</mml:mi>
441 <mml:mi mathvariant=
"italic">x
</mml:mi>
444 <mml:mo>⁢</mml:mo>
445 <mml:mi mathvariant=
"italic">i
</mml:mi>
448 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
449 <mml:mi mathvariant=
"italic">r
</mml:mi>
452 <mml:mfenced open=
"" close=
"">
453 <mml:msub><mml:mi mathvariant=
"italic">zoom
</mml:mi>
454 <mml:mi mathvariant=
"italic">y
</mml:mi>
457 <mml:mo>⁢</mml:mo>
458 <mml:mi mathvariant=
"italic">j
</mml:mi>
461 </mml:math></inlineequation>
467 <inlineequation><mml:math>
468 <!-- eqn: (x sub r + {zoom sub x} (i + 1), y sub r + {zoom sub y} ( j + 1 )):-->
469 <mml:mfenced open=
"(" close=
")">
471 <mml:msub><mml:mi mathvariant=
"italic">x
</mml:mi>
472 <mml:mi mathvariant=
"italic">r
</mml:mi>
476 <mml:mfenced open=
"" close=
"">
477 <mml:msub><mml:mi mathvariant=
"italic">zoom
</mml:mi>
478 <mml:mi mathvariant=
"italic">x
</mml:mi>
481 <mml:mo>⁡</mml:mo>
482 <mml:mfenced open=
"(" close=
")">
484 <mml:mi mathvariant=
"italic">i
</mml:mi>
492 <mml:msub><mml:mi mathvariant=
"italic">y
</mml:mi>
493 <mml:mi mathvariant=
"italic">r
</mml:mi>
497 <mml:mfenced open=
"" close=
"">
498 <mml:msub><mml:mi mathvariant=
"italic">zoom
</mml:mi>
499 <mml:mi mathvariant=
"italic">y
</mml:mi>
502 <mml:mo>⁡</mml:mo>
503 <mml:mfenced open=
"(" close=
")">
505 <mml:mi mathvariant=
"italic">j
</mml:mi>
513 </mml:math></inlineequation>
517 <inlineequation><mml:math>
518 <!-- eqn: zoom sub x:-->
519 <mml:msub><mml:mi mathvariant=
"italic">zoom
</mml:mi>
520 <mml:mi mathvariant=
"italic">x
</mml:mi>
522 </mml:math></inlineequation>
523 is the value of
<constant>GL_ZOOM_X
</constant> and
524 <inlineequation><mml:math>
525 <!-- eqn: zoom sub y:-->
526 <mml:msub><mml:mi mathvariant=
"italic">zoom
</mml:mi>
527 <mml:mi mathvariant=
"italic">y
</mml:mi>
529 </mml:math></inlineequation>
530 is the value of
<constant>GL_ZOOM_Y
</constant>.
533 <refsect1 id=
"examples"><title>Examples
</title>
535 To copy the color pixel in the lower left corner of the window to the current raster position,
540 glCopyPixels(
0,
0,
1,
1,
<constant>GL_COLOR
</constant>);
546 <refsect1 id=
"notes"><title>Notes
</title>
548 Modes specified by
<citerefentry><refentrytitle>glPixelStore
</refentrytitle></citerefentry> have no effect on the operation
549 of
<function>glCopyPixels
</function>.
552 <refsect1 id=
"errors"><title>Errors
</title>
554 <constant>GL_INVALID_ENUM
</constant> is generated if
<parameter>type
</parameter> is not an accepted value.
557 <constant>GL_INVALID_VALUE
</constant> is generated if either
<parameter>width
</parameter> or
<parameter>height
</parameter> is negative.
560 <constant>GL_INVALID_OPERATION
</constant> is generated if
<parameter>type
</parameter> is
<constant>GL_DEPTH
</constant>
561 and there is no depth buffer.
564 <constant>GL_INVALID_OPERATION
</constant> is generated if
<parameter>type
</parameter> is
<constant>GL_STENCIL
</constant>
565 and there is no stencil buffer.
568 <constant>GL_INVALID_OPERATION
</constant> is generated if
<function>glCopyPixels
</function>
569 is executed between the execution of
<citerefentry><refentrytitle>glBegin
</refentrytitle></citerefentry>
570 and the corresponding execution of
<citerefentry><refentrytitle>glEnd
</refentrytitle></citerefentry>.
573 <refsect1 id=
"associatedgets"><title>Associated Gets
</title>
575 <citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
<constant>GL_CURRENT_RASTER_POSITION
</constant>
578 <citerefentry><refentrytitle>glGet
</refentrytitle></citerefentry> with argument
<constant>GL_CURRENT_RASTER_POSITION_VALID
</constant>
581 <refsect1 id=
"seealso"><title>See Also
</title>
583 <citerefentry><refentrytitle>glColorTable
</refentrytitle></citerefentry>,
584 <citerefentry><refentrytitle>glConvolutionFilter1D
</refentrytitle></citerefentry>,
585 <citerefentry><refentrytitle>glConvolutionFilter2D
</refentrytitle></citerefentry>,
586 <citerefentry><refentrytitle>glDepthFunc
</refentrytitle></citerefentry>,
587 <citerefentry><refentrytitle>glDrawBuffer
</refentrytitle></citerefentry>,
588 <citerefentry><refentrytitle>glDrawPixels
</refentrytitle></citerefentry>,
589 <citerefentry><refentrytitle>glMatrixMode
</refentrytitle></citerefentry>,
590 <citerefentry><refentrytitle>glPixelMap
</refentrytitle></citerefentry>,
591 <citerefentry><refentrytitle>glPixelTransfer
</refentrytitle></citerefentry>,
592 <citerefentry><refentrytitle>glPixelZoom
</refentrytitle></citerefentry>,
593 <citerefentry><refentrytitle>glRasterPos
</refentrytitle></citerefentry>,
594 <citerefentry><refentrytitle>glReadBuffer
</refentrytitle></citerefentry>,
595 <citerefentry><refentrytitle>glReadPixels
</refentrytitle></citerefentry>,
596 <citerefentry><refentrytitle>glSeparableFilter2D
</refentrytitle></citerefentry>,
597 <citerefentry><refentrytitle>glStencilFunc
</refentrytitle></citerefentry>,
598 <citerefentry><refentrytitle>glWindowPos
</refentrytitle></citerefentry>
601 <refsect1 id=
"Copyright"><title>Copyright
</title>
603 Copyright
<trademark class=
"copyright"></trademark> 1991-
2006
604 Silicon Graphics, Inc. This document is licensed under the SGI
605 Free Software B License. For details, see
606 <ulink url=
"http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/
</ulink>.