Opentk/Source/Bind/Specifications/Docs/glCopyPixels.xml
2009-03-08 00:46:58 +00:00

609 lines
32 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook MathML Module V1.1b1//EN"
"http://www.oasis-open.org/docbook/xml/mathml/1.1CR1/dbmathml.dtd">
<refentry id="glCopyPixels">
<refmeta>
<refmetainfo>
<copyright>
<year>1991-2006</year>
<holder>Silicon Graphics, Inc.</holder>
</copyright>
</refmetainfo>
<refentrytitle>glCopyPixels</refentrytitle>
<manvolnum>3G</manvolnum>
</refmeta>
<refnamediv>
<refname>glCopyPixels</refname>
<refpurpose>copy pixels in the frame buffer</refpurpose>
</refnamediv>
<refsynopsisdiv><title>C Specification</title>
<funcsynopsis>
<funcprototype>
<funcdef>void <function>glCopyPixels</function></funcdef>
<paramdef>GLint <parameter>x</parameter></paramdef>
<paramdef>GLint <parameter>y</parameter></paramdef>
<paramdef>GLsizei <parameter>width</parameter></paramdef>
<paramdef>GLsizei <parameter>height</parameter></paramdef>
<paramdef>GLenum <parameter>type</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<!-- eqn: ignoring delim $$ -->
<refsect1 id="parameters"><title>Parameters</title>
<variablelist>
<varlistentry>
<term><parameter>x</parameter></term>
<term><parameter>y</parameter></term>
<listitem>
<para>
Specify the window coordinates of the lower left corner
of the rectangular region of pixels to be copied.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>width</parameter></term>
<term><parameter>height</parameter></term>
<listitem>
<para>
Specify the dimensions of the rectangular region of pixels to be copied.
Both must be nonnegative.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>type</parameter></term>
<listitem>
<para>
Specifies whether color values,
depth values,
or stencil values are to be copied.
Symbolic constants
<constant>GL_COLOR</constant>,
<constant>GL_DEPTH</constant>,
and <constant>GL_STENCIL</constant> are accepted.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 id="description"><title>Description</title>
<para>
<function>glCopyPixels</function> 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.
</para>
<para>
<parameter>x</parameter> and <parameter>y</parameter> specify the window coordinates of
the lower left corner of the rectangular region to be copied.
<parameter>width</parameter> and <parameter>height</parameter> specify the dimensions of the
rectangular region to be copied.
Both <parameter>width</parameter> and <parameter>height</parameter> must not be negative.
</para>
<para>
Several parameters control the processing of the pixel data
while it is being copied.
These parameters are set with three commands:
<citerefentry><refentrytitle>glPixelTransfer</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glPixelMap</refentrytitle></citerefentry>, and
<citerefentry><refentrytitle>glPixelZoom</refentrytitle></citerefentry>.
This reference page describes the effects on <function>glCopyPixels</function> of most,
but not all, of the parameters specified by these three commands.
</para>
<para>
<function>glCopyPixels</function> copies values from each pixel with the lower left-hand corner at
<inlineequation><mml:math>
<!-- eqn: (x + i, y + j):-->
<mml:mfenced open="(" close=")">
<mml:mrow>
<mml:mi mathvariant="italic">x</mml:mi>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">i</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:mi mathvariant="italic">y</mml:mi>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">j</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:math></inlineequation>
for
<inlineequation><mml:math>
<!-- eqn: 0 <= i < width:-->
<mml:mrow>
<mml:mn>0</mml:mn>
<mml:mo>&lt;=</mml:mo>
<mml:mi mathvariant="italic">i</mml:mi>
<mml:mo>&lt;</mml:mo>
<mml:mi mathvariant="italic">width</mml:mi>
</mml:mrow>
</mml:math></inlineequation>
and
<inlineequation><mml:math>
<!-- eqn: 0 <= j < height:-->
<mml:mrow>
<mml:mn>0</mml:mn>
<mml:mo>&lt;=</mml:mo>
<mml:mi mathvariant="italic">j</mml:mi>
<mml:mo>&lt;</mml:mo>
<mml:mi mathvariant="italic">height</mml:mi>
</mml:mrow>
</mml:math></inlineequation>.
This pixel is said to be the
<inlineequation><mml:math><mml:mi mathvariant="italic">i</mml:mi></mml:math></inlineequation>th
pixel in the
<inlineequation><mml:math><mml:mi mathvariant="italic">j</mml:mi></mml:math></inlineequation>th
row.
Pixels are copied in row order from the lowest to the highest row,
left to right in each row.
</para>
<para>
<parameter>type</parameter> specifies whether color, depth, or stencil data is to be copied.
The details of the transfer for each data type are as follows:
</para>
<variablelist>
<varlistentry>
<term><constant>GL_COLOR</constant></term>
<listitem>
<para>
Indices or RGBA colors are read from the buffer currently specified as the
read source buffer (see <citerefentry><refentrytitle>glReadBuffer</refentrytitle></citerefentry>).
If the GL is in color index mode,
each index that is read from this buffer is converted
to a fixed-point format with an unspecified
number of bits to the right of the binary point.
Each index is then shifted left by <constant>GL_INDEX_SHIFT</constant> bits,
and added to <constant>GL_INDEX_OFFSET</constant>.
If <constant>GL_INDEX_SHIFT</constant> is negative,
the shift is to the right.
In either case, zero bits fill otherwise unspecified bit locations in the
result.
If <constant>GL_MAP_COLOR</constant> is true,
the index is replaced with the value that it references in lookup table
<constant>GL_PIXEL_MAP_I_TO_I</constant>.
Whether the lookup replacement of the index is done or not,
the integer part of the index is then ANDed with
<inlineequation><mml:math>
<!-- eqn: 2 sup b -1:-->
<mml:mrow>
<mml:msup><mml:mn>2</mml:mn>
<mml:mi mathvariant="italic">b</mml:mi>
</mml:msup>
<mml:mo>-</mml:mo>
<mml:mn>1</mml:mn>
</mml:mrow>
</mml:math></inlineequation>,
where
<inlineequation><mml:math><mml:mi mathvariant="italic">b</mml:mi></mml:math></inlineequation>
is the number of bits in a color index buffer.
</para>
<para>
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 <constant>GL_c_SCALE</constant> and added to <constant>GL_c_BIAS</constant>,
where <emphasis>c</emphasis> is RED, GREEN, BLUE, and ALPHA
for the respective color components.
The results are clamped to the range [0,1].
If <constant>GL_MAP_COLOR</constant> is true,
each color component is scaled by the size of lookup table
<constant>GL_PIXEL_MAP_c_TO_c</constant>,
then replaced by the value that it references in that table.
<emphasis>c</emphasis> is R, G, B, or A.
</para>
<para>
If the <code>ARB_imaging</code> extension is supported, the color values may
be
additionally processed by color-table lookups, color-matrix
transformations, and convolution filters.
</para>
<para>
The GL then converts the resulting indices or RGBA colors to fragments
by attaching the current raster position <emphasis>z</emphasis> coordinate and
texture coordinates to each pixel,
then assigning window coordinates
<inlineequation><mml:math>
<!-- eqn: (x sub r + i , y sub r + j):-->
<mml:mfenced open="(" close=")">
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">x</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">i</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">y</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">j</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:math></inlineequation>,
where
<inlineequation><mml:math>
<!-- eqn: (x sub r , y sub r):-->
<mml:mfenced open="(" close=")">
<mml:msub><mml:mi mathvariant="italic">x</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:msub><mml:mi mathvariant="italic">y</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
</mml:mfenced>
</mml:math></inlineequation>
is the current raster position,
and the pixel was the
<inlineequation><mml:math><mml:mi mathvariant="italic">i</mml:mi></mml:math></inlineequation>th
pixel in the
<inlineequation><mml:math><mml:mi mathvariant="italic">j</mml:mi></mml:math></inlineequation>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.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>GL_DEPTH</constant></term>
<listitem>
<para>
Depth values are read from the depth buffer and
converted directly to an internal floating-point format
with unspecified precision.
The resulting floating-point depth value is then multiplied
by <constant>GL_DEPTH_SCALE</constant> and added to <constant>GL_DEPTH_BIAS</constant>.
The result is clamped to the range [0,1].
</para>
<para>
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
<inlineequation><mml:math>
<!-- eqn: (x sub r + i , y sub r + j):-->
<mml:mfenced open="(" close=")">
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">x</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">i</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">y</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">j</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:math></inlineequation>,
where
<inlineequation><mml:math>
<!-- eqn: (x sub r , y sub r):-->
<mml:mfenced open="(" close=")">
<mml:msub><mml:mi mathvariant="italic">x</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:msub><mml:mi mathvariant="italic">y</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
</mml:mfenced>
</mml:math></inlineequation>
is the current raster position,
and the pixel was the
<inlineequation><mml:math><mml:mi mathvariant="italic">i</mml:mi></mml:math></inlineequation>th
pixel in the
<inlineequation><mml:math><mml:mi mathvariant="italic">j</mml:mi></mml:math></inlineequation>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.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>GL_STENCIL</constant></term>
<listitem>
<para>
Stencil indices are read from the stencil buffer and
converted to an internal fixed-point format
with an unspecified number of bits to the right of the binary point.
Each fixed-point index is then shifted left by <constant>GL_INDEX_SHIFT</constant> bits,
and added to <constant>GL_INDEX_OFFSET</constant>.
If <constant>GL_INDEX_SHIFT</constant> is negative,
the shift is to the right.
In either case, zero bits fill otherwise unspecified bit locations in the
result.
If <constant>GL_MAP_STENCIL</constant> is true,
the index is replaced with the value that it references in lookup table
<constant>GL_PIXEL_MAP_S_TO_S</constant>.
Whether the lookup replacement of the index is done or not,
the integer part of the index is then ANDed with
<inlineequation><mml:math>
<!-- eqn: 2 sup b -1:-->
<mml:mrow>
<mml:msup><mml:mn>2</mml:mn>
<mml:mi mathvariant="italic">b</mml:mi>
</mml:msup>
<mml:mo>-</mml:mo>
<mml:mn>1</mml:mn>
</mml:mrow>
</mml:math></inlineequation>,
where
<inlineequation><mml:math><mml:mi mathvariant="italic">b</mml:mi></mml:math></inlineequation>
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
<inlineequation><mml:math><mml:mi mathvariant="italic">i</mml:mi></mml:math></inlineequation>th
location of the
<inlineequation><mml:math><mml:mi mathvariant="italic">j</mml:mi></mml:math></inlineequation>th
row
is written to location
<inlineequation><mml:math>
<!-- eqn: (x sub r + i , y sub r + j):-->
<mml:mfenced open="(" close=")">
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">x</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">i</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">y</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:mo>+</mml:mo>
<mml:mi mathvariant="italic">j</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:math></inlineequation>,
where
<inlineequation><mml:math>
<!-- eqn: (x sub r , y sub r):-->
<mml:mfenced open="(" close=")">
<mml:msub><mml:mi mathvariant="italic">x</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:msub><mml:mi mathvariant="italic">y</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
</mml:mfenced>
</mml:math></inlineequation>
is the current raster position.
Only the pixel ownership test,
the scissor test,
and the stencil writemask affect these write operations.
</para>
</listitem>
</varlistentry>
</variablelist>
<para>
The rasterization described thus far assumes pixel zoom factors of 1.0.
If
<citerefentry><refentrytitle>glPixelZoom</refentrytitle></citerefentry> is used to change the
<inlineequation><mml:math><mml:mi mathvariant="italic">x</mml:mi></mml:math></inlineequation>
and
<inlineequation><mml:math><mml:mi mathvariant="italic">y</mml:mi></mml:math></inlineequation>
pixel zoom factors,
pixels are converted to fragments as follows.
If
<inlineequation><mml:math>
<!-- eqn: (x sub r, y sub r):-->
<mml:mfenced open="(" close=")">
<mml:msub><mml:mi mathvariant="italic">x</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:msub><mml:mi mathvariant="italic">y</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
</mml:mfenced>
</mml:math></inlineequation>
is the current raster position,
and a given pixel is in the
<inlineequation><mml:math><mml:mi mathvariant="italic">i</mml:mi></mml:math></inlineequation>th
location in the
<inlineequation><mml:math><mml:mi mathvariant="italic">j</mml:mi></mml:math></inlineequation>th
row of the source
pixel rectangle,
then fragments are generated for pixels whose centers are in the rectangle
with corners at
</para>
<para>
<inlineequation><mml:math>
<!-- eqn: (x sub r + {zoom sub x} i, y sub r + {zoom sub y} j):-->
<mml:mfenced open="(" close=")">
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">x</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:mo>+</mml:mo>
<mml:mfenced open="" close="">
<mml:msub><mml:mi mathvariant="italic">zoom</mml:mi>
<mml:mi mathvariant="italic">x</mml:mi>
</mml:msub>
</mml:mfenced>
<mml:mo>&it;</mml:mo>
<mml:mi mathvariant="italic">i</mml:mi>
</mml:mrow>
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">y</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:mo>+</mml:mo>
<mml:mfenced open="" close="">
<mml:msub><mml:mi mathvariant="italic">zoom</mml:mi>
<mml:mi mathvariant="italic">y</mml:mi>
</mml:msub>
</mml:mfenced>
<mml:mo>&it;</mml:mo>
<mml:mi mathvariant="italic">j</mml:mi>
</mml:mrow>
</mml:mfenced>
</mml:math></inlineequation>
</para>
<para>
and
</para>
<para>
<inlineequation><mml:math>
<!-- eqn: (x sub r + {zoom sub x} (i + 1), y sub r + {zoom sub y} ( j + 1 )):-->
<mml:mfenced open="(" close=")">
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">x</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:mo>+</mml:mo>
<mml:mrow>
<mml:mfenced open="" close="">
<mml:msub><mml:mi mathvariant="italic">zoom</mml:mi>
<mml:mi mathvariant="italic">x</mml:mi>
</mml:msub>
</mml:mfenced>
<mml:mo>&af;</mml:mo>
<mml:mfenced open="(" close=")">
<mml:mrow>
<mml:mi mathvariant="italic">i</mml:mi>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
</mml:mrow>
</mml:mfenced>
</mml:mrow>
</mml:mrow>
<mml:mrow>
<mml:msub><mml:mi mathvariant="italic">y</mml:mi>
<mml:mi mathvariant="italic">r</mml:mi>
</mml:msub>
<mml:mo>+</mml:mo>
<mml:mrow>
<mml:mfenced open="" close="">
<mml:msub><mml:mi mathvariant="italic">zoom</mml:mi>
<mml:mi mathvariant="italic">y</mml:mi>
</mml:msub>
</mml:mfenced>
<mml:mo>&af;</mml:mo>
<mml:mfenced open="(" close=")">
<mml:mrow>
<mml:mi mathvariant="italic">j</mml:mi>
<mml:mo>+</mml:mo>
<mml:mn>1</mml:mn>
</mml:mrow>
</mml:mfenced>
</mml:mrow>
</mml:mrow>
</mml:mfenced>
</mml:math></inlineequation>
</para>
<para>
where
<inlineequation><mml:math>
<!-- eqn: zoom sub x:-->
<mml:msub><mml:mi mathvariant="italic">zoom</mml:mi>
<mml:mi mathvariant="italic">x</mml:mi>
</mml:msub>
</mml:math></inlineequation>
is the value of <constant>GL_ZOOM_X</constant> and
<inlineequation><mml:math>
<!-- eqn: zoom sub y:-->
<mml:msub><mml:mi mathvariant="italic">zoom</mml:mi>
<mml:mi mathvariant="italic">y</mml:mi>
</mml:msub>
</mml:math></inlineequation>
is the value of <constant>GL_ZOOM_Y</constant>.
</para>
</refsect1>
<refsect1 id="examples"><title>Examples</title>
<para>
To copy the color pixel in the lower left corner of the window to the current raster position,
use
</para>
<para>
<programlisting>
glCopyPixels(0, 0, 1, 1, <constant>GL_COLOR</constant>);
</programlisting>
</para>
<para>
</para>
</refsect1>
<refsect1 id="notes"><title>Notes</title>
<para>
Modes specified by <citerefentry><refentrytitle>glPixelStore</refentrytitle></citerefentry> have no effect on the operation
of <function>glCopyPixels</function>.
</para>
</refsect1>
<refsect1 id="errors"><title>Errors</title>
<para>
<constant>GL_INVALID_ENUM</constant> is generated if <parameter>type</parameter> is not an accepted value.
</para>
<para>
<constant>GL_INVALID_VALUE</constant> is generated if either <parameter>width</parameter> or <parameter>height</parameter> is negative.
</para>
<para>
<constant>GL_INVALID_OPERATION</constant> is generated if <parameter>type</parameter> is <constant>GL_DEPTH</constant>
and there is no depth buffer.
</para>
<para>
<constant>GL_INVALID_OPERATION</constant> is generated if <parameter>type</parameter> is <constant>GL_STENCIL</constant>
and there is no stencil buffer.
</para>
<para>
<constant>GL_INVALID_OPERATION</constant> is generated if <function>glCopyPixels</function>
is executed between the execution of <citerefentry><refentrytitle>glBegin</refentrytitle></citerefentry>
and the corresponding execution of <citerefentry><refentrytitle>glEnd</refentrytitle></citerefentry>.
</para>
</refsect1>
<refsect1 id="associatedgets"><title>Associated Gets</title>
<para>
<citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_CURRENT_RASTER_POSITION</constant>
</para>
<para>
<citerefentry><refentrytitle>glGet</refentrytitle></citerefentry> with argument <constant>GL_CURRENT_RASTER_POSITION_VALID</constant>
</para>
</refsect1>
<refsect1 id="seealso"><title>See Also</title>
<para>
<citerefentry><refentrytitle>glColorTable</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glConvolutionFilter1D</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glConvolutionFilter2D</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glDepthFunc</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glDrawBuffer</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glDrawPixels</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glMatrixMode</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glPixelMap</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glPixelTransfer</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glPixelZoom</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glRasterPos</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glReadBuffer</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glReadPixels</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glSeparableFilter2D</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glStencilFunc</refentrytitle></citerefentry>,
<citerefentry><refentrytitle>glWindowPos</refentrytitle></citerefentry>
</para>
</refsect1>
<refsect1 id="Copyright"><title>Copyright</title>
<para>
Copyright <trademark class="copyright"></trademark> 1991-2006
Silicon Graphics, Inc. This document is licensed under the SGI
Free Software B License. For details, see
<ulink url="http://oss.sgi.com/projects/FreeB/">http://oss.sgi.com/projects/FreeB/</ulink>.
</para>
</refsect1>
</refentry>