<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html
  PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN" "http://www.w3.org/TR/MathML2/dtd/xhtml-math11-f.dtd">
<html
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:mml="http://www.w3.org/1998/Math/MathML"
><head><title>glReadPixels</title><link rel="stylesheet" href="style.css" type="text/css"/><meta name="generator" content="DocBook XSL Stylesheets V1.59.1"/><link rel="home" href="index.xml" title="PyOpenGL 2.0.1.09 Man Pages"/><link rel="up" href="reference-GL.xml" title="GL"/><link rel="previous" href="glReadBuffer.3G.xml" title="glReadBuffer"/><link rel="next" href="glRect.3G.xml" title="glRect"/></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">glReadPixels</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="glReadBuffer.3G.xml">Prev</a> </td><th width="60%" align="center">GL</th><td width="20%" align="right"> <a accesskey="n" href="glRect.3G.xml">Next</a></td></tr></table><hr/></div><div class="refentry" lang="en"><a name="glReadPixels.3G"/><div class="titlepage"/><div class="refnamediv"><a name="glReadPixels.3G-name"/><h2>Name</h2><p>glReadPixels, glReadPixelsb, glReadPixelsd, glReadPixelsf, glReadPixelsi, glReadPixelss, glReadPixelsub, glReadPixelsui, glReadPixelsus &#8212; read a block of pixels from the frame buffer</p></div><div class="refsynopsisdiv"><a name="glReadPixels.3G-c_spec"/><h2>C Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code>void <tt>glReadPixels</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code>GLint <i><tt>x</tt></i>, GLint <i><tt>y</tt></i>, GLsizei <i><tt>width</tt></i>, GLsizei <i><tt>height</tt></i>, GLenum <i><tt>format</tt></i>, GLenum <i><tt>type</tt></i>, GLvoid *<i><tt>pixels</tt></i>);</code></td></tr></table></div><div class="refsynopsisdiv"><a name="glReadPixels.3G-python_spec"/><h2>Python Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code><tt>glReadPixels</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>x</tt></i>, <i><tt>y</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>format</tt></i>, <i><tt>type</tt></i>) &#8594; <i><tt>pixels</tt></i></code></td></tr><tr><td valign="top"><code><tt>glReadPixelsb</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>x</tt></i>, <i><tt>y</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glReadPixelsd</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>x</tt></i>, <i><tt>y</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glReadPixelsf</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>x</tt></i>, <i><tt>y</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glReadPixelsi</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>x</tt></i>, <i><tt>y</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glReadPixelss</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>x</tt></i>, <i><tt>y</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glReadPixelsub</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>x</tt></i>, <i><tt>y</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glReadPixelsui</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>x</tt></i>, <i><tt>y</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr><tr><td valign="top"><code><tt>glReadPixelsus</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>x</tt></i>, <i><tt>y</tt></i>, <i><tt>width</tt></i>, <i><tt>height</tt></i>, <i><tt>format</tt></i>) &#8594; <i><tt>pixels</tt></i>[][][]</code></td></tr></table></div><div class="refsect1" lang="en"><a name="glReadPixels.3G-parameters"/><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><i><tt>x</tt></i>, <i><tt>y</tt></i></span></dt><dd>
						Specify the window coordinates of the first pixel that is read from the frame buffer. This location is the
						lower left corner of a rectangular block of pixels.
					</dd><dt><span class="term"><i><tt>width</tt></i>, <i><tt>height</tt></i></span></dt><dd>
						Specify the dimensions of the pixel rectangle. <i><tt>width</tt></i> and
						<i><tt>height</tt></i> of one correspond to a single pixel.
					</dd><dt><span class="term"><i><tt>format</tt></i></span></dt><dd>
						Specifies the of the pixel data. The following symbolic values are accepted:
						<tt>GL_COLOR_INDEX</tt>, <tt>GL_STENCIL_INDEX</tt>,
						<tt>GL_DEPTH_COMPONENT</tt>, <tt>GL_RED</tt>, <tt>GL_GREEN</tt>,
						<tt>GL_BLUE</tt>, <tt>GL_ALPHA</tt>, <tt>GL_RGB</tt>,
						<tt>GL_BGR</tt>, <tt>GL_RGBA</tt>, <tt>GL_BGRA</tt>,
						<tt>GL_LUMINANCE</tt>, and <tt>GL_LUMINANCE_ALPHA</tt>.
					</dd><dt><span class="term"><i><tt>type</tt></i></span></dt><dd>
						Specifies the data type of the pixel data. Must be one of <tt>GL_UNSIGNED_BYTE</tt>,
						<tt>GL_BYTE</tt>, <tt>GL_BITMAP</tt>, <tt>GL_UNSIGNED_SHORT</tt>,
						<tt>GL_SHORT</tt>, <tt>GL_UNSIGNED_INT</tt>, <tt>GL_INT</tt>,
						<tt>GL_FLOAT</tt>, <tt>GL_UNSIGNED_BYTE_3_3_2</tt>,
						<tt>GL_UNSIGNED_BYTE_2_3_3_REV</tt>, <tt>GL_UNSIGNED_SHORT_5_6_5</tt>,
						<tt>GL_UNSIGNED_SHORT_5_6_5_REV</tt>, <tt>GL_UNSIGNED_SHORT_4_4_4_4</tt>,
						<tt>GL_UNSIGNED_SHORT_4_4_4_4_REV</tt>, <tt>GL_UNSIGNED_SHORT_5_5_5_1</tt>,
						<tt>GL_UNSIGNED_SHORT_1_5_5_5_REV</tt>, <tt>GL_UNSIGNED_INT_8_8_8_8</tt>,
						<tt>GL_UNSIGNED_INT_8_8_8_8_REV</tt>, <tt>GL_UNSIGNED_INT_10_10_10_2</tt>, or
						<tt>GL_UNSIGNED_INT_2_10_10_10_REV</tt>.
					</dd><dt><span class="term"><i><tt>pixels</tt></i></span></dt><dd>
						Returns the pixel data.
					</dd></dl></div></div><div class="refsect1" lang="en"><a name="glReadPixels.3G-description"/><h2>Description</h2><p>
			<tt>glReadPixels</tt> returns pixel data from the frame buffer, starting with the pixel whose lower left
			corner is at location (<i><tt>x</tt></i>, <i><tt>y</tt></i>), into client memory starting at location
			<i><tt>pixels</tt></i>. Several parameters control the processing of the pixel data before it is placed into
			client memory. These parameters are set with three commands: <tt>glPixelStore</tt>,
			<tt>glPixelTransfer</tt>, and <tt>glPixelMap</tt>. This
			reference page describes the effects on <tt>glReadPixels</tt> of most, but not all of the parameters
			specified by these three commands.
		</p><p>
			When the <tt>GL_ARB_imaging</tt> extension is supported, the pixel data may be processed by additional
			operations including color table lookup, color matrix tranformations, convolutions, histograms and minimum and maximun
			pixel value computations.
		</p><p>
			<tt>glReadPixels</tt> returns values from each pixel with lower left corner at (<i><tt>x</tt></i> +
			<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>i</mml:mi>
				</mml:math>, <i><tt>y</tt></i> + <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>j</mml:mi>
				</mml:math>) for 0 &#8804; <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>i</mml:mi>
				</mml:math> &lt; <i><tt>width</tt></i> and 0 &#8804; <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>j</mml:mi>
				</mml:math> &lt; <i><tt>height</tt></i>. This pixel is said to be the <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>i</mml:mi>
				</mml:math>th pixel in the <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>j</mml:mi>
				</mml:math>th row. Pixels are returned in row order from the lowest to the highest row, left to right in each row.
		</p><p>
			<i><tt>format</tt></i> specifies the for the returned pixel values; accepted values are:
		</p><div class="variablelist"><dl><dt><span class="term"><tt>GL_COLOR_INDEX</tt></span></dt><dd>
						Color indices are read from the color buffer selected by <a href="glReadBuffer.3G.xml"><tt>glReadBuffer</tt></a>. Each index is converted to fixed point, shifted left or right
						depending on the value and sign of <tt>GL_INDEX_SHIFT</tt>, and added to
						<tt>GL_INDEX_OFFSET</tt>. If <tt>GL_MAP_COLOR</tt> is <tt>GL_TRUE</tt>,
						indices are replaced by their mappings in the table <tt>GL_PIXEL_MAP_I_TO_I</tt>.
					</dd><dt><span class="term"><tt>GL_STENCIL_INDEX</tt></span></dt><dd>
						Stencil values are read from the stencil buffer. Each index is converted to fixed point, shifted left or
						right depending on the value and sign of <tt>GL_INDEX_SHIFT</tt>, and added to
						<tt>GL_INDEX_OFFSET</tt>. If <tt>GL_MAP_STENCIL</tt> is
						<tt>GL_TRUE</tt>, indices are replaced by their mappings in the table
						<tt>GL_PIXEL_MAP_S_TO_S</tt>.
					</dd><dt><span class="term"><tt>GL_DEPTH_COMPONENT</tt></span></dt><dd>
						Depth values are read from the depth buffer. Each component is converted to floating point such that the
						minimum depth value maps to 0 and the maximum value maps to 1. Each component is then multiplied by
						<tt>GL_DEPTH_SCALE</tt>, added to <tt>GL_DEPTH_BIAS</tt>, and finally clamped to
						the range [0,1].
					</dd><dt><span class="term"><tt>GL_GREEN</tt>, </span><span class="term"><tt>GL_BLUE</tt>, </span><span class="term"><tt>GL_ALPHA</tt>, </span><span class="term"><tt>GL_RGB</tt>, </span><span class="term"><tt>GL_BGR</tt>, </span><span class="term"><tt>GL_RGBA</tt>, </span><span class="term"><tt>GL_BGRA</tt>, </span><span class="term"><tt>GL_LUMINANCE</tt>, </span><span class="term"><tt>GL_LUMINANCE_ALPHA</tt>, </span><span class="term"><tt>GL_RED</tt></span></dt><dd><p>
						Processing differs depending on whether color buffers store color indices or RGBA color components. If
						color indices are stored, they are read from the color buffer selected by <a href="glReadBuffer.3G.xml"><tt>glReadBuffer</tt></a>. Each index is converted to fixed point, shifted left or right
						depending on the value and sign of <tt>GL_INDEX_SHIFT</tt>, and added to
						<tt>GL_INDEX_OFFSET</tt>. Indices are then replaced by the red, green, blue, and alpha values
						obtained by indexing the tables <tt>GL_PIXEL_MAP_I_TO_R</tt>,
						<tt>GL_PIXEL_MAP_I_TO_G</tt>, <tt>GL_PIXEL_MAP_I_TO_B</tt>, and
						<tt>GL_PIXEL_MAP_I_TO_A</tt>. Each table must be of size <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:msup>
									<mml:mn>2</mml:mn>
									<mml:mi>n</mml:mi>
								</mml:msup>
							</mml:math>, but <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mi>n</mml:mi>
							</mml:math> may be different for different tables. Before an index is used to look up a value in a
						table of size <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:msup>
									<mml:mn>2</mml:mn>
									<mml:mi>n</mml:mi>
								</mml:msup>
							</mml:math>, it must be masked against <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:msup>
										<mml:mn>2</mml:mn>
										<mml:mi>n</mml:mi>
									</mml:msup>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
								</mml:mrow>
							</mml:math>.
					</p><p>
						If RGBA color components are stored in the color buffers, they are read from the color buffer selected by
						<a href="glReadBuffer.3G.xml"><tt>glReadBuffer</tt></a>. Each color component is converted to floating point
						such that zero intensity maps to 0.0 and full intensity maps to 1.0. Each component is then multiplied by
						<tt>GL_c_SCALE</tt> and added to <tt>GL_c_BIAS</tt>, where <i><tt>c</tt></i>
						is RED, GREEN, BLUE, or ALPHA. Finally, if <tt>GL_MAP_COLOR</tt> is
						<tt>GL_TRUE</tt>, each component is clamped to the range [0,1], scaled to the size of its
						corresponding table, and is then replaced by its mapping in the table
						<tt>GL_PIXEL_MAP_c_TO_c</tt>, where <i><tt>c</tt></i> is R, G, B, or A.
					</p><p>
						Unneeded data is then discarded. For example, <tt>GL_RED</tt> discards the green, blue, and
						alpha components, while <tt>GL_RGB</tt> discards only the alpha component.
						<tt>GL_LUMINANCE</tt> computes a single-component value as the sum of the red, green, and blue
						components, and <tt>GL_LUMINANCE_ALPHA</tt> does the same, while keeping alpha as a second
						value. The final values are clamped to the range [0,1].
					</p></dd></dl></div><p>
			The shift, scale, bias, and lookup factors just described are all specified by
		</p><p>
			<tt>glPixelTransfer</tt>. The lookup table contents themselves are specified by
			<tt>glPixelMap</tt>.
		</p><p>
			Finally, the indices or components are converted to the proper , as specified by <i><tt>type</tt></i>. If
			<i><tt>format</tt></i> is <tt>GL_COLOR_INDEX</tt> or <tt>GL_STENCIL_INDEX</tt> and
			<i><tt>type</tt></i> is not <tt>GL_FLOAT</tt>, each index is masked with the mask value given in the
			following table. If <i><tt>type</tt></i> is <tt>GL_FLOAT</tt>, then each integer index is converted
			to single-precision floating-point .
		</p><p>
			If <i><tt>format</tt></i> is <tt>GL_RED</tt>, <tt>GL_GREEN</tt>,
			<tt>GL_BLUE</tt>, <tt>GL_ALPHA</tt>, <tt>GL_RGB</tt>, <tt>GL_BGR</tt>,
			<tt>GL_RGBA</tt>, <tt>GL_BGRA</tt>, <tt>GL_LUMINANCE</tt>, or
			<tt>GL_LUMINANCE_ALPHA</tt> and <i><tt>type</tt></i> is not <tt>GL_FLOAT</tt>, each
			component is multiplied by the multiplier shown in the following table. If type is <tt>GL_FLOAT</tt>, then
			each component is passed as is (or converted to the client's single-precision floating-point if it is different from
			the one used by the GL).
		</p><div class="informaltable"><table border="1"><colgroup><col/><col/><col/></colgroup><tbody><tr><td><i><tt>type</tt></i></td><td align="center"><span class="bold"><b>index mask</b></span></td><td align="center"><span class="bold"><b>component conversion</b></span></td></tr><tr><td><tt>GL_UNSIGNED_BYTE</tt></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>8</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
								</mml:mrow>
							</mml:math></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mo>(</mml:mo>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>8</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
									<mml:mo>)</mml:mo>
									<mml:mi>c</mml:mi>
								</mml:mrow>
							</mml:math></td></tr><tr><td><tt>GL_BYTE</tt></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>7</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
								</mml:mrow>
							</mml:math></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mo>[</mml:mo>
									<mml:mo>(</mml:mo>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>8</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
									<mml:mo>)</mml:mo>
									<mml:mi>c</mml:mi>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
									<mml:mo>]</mml:mo>
									<mml:mo>/</mml:mo>
									<mml:mn>2</mml:mn>
								</mml:mrow>
							</mml:math></td></tr><tr><td><tt>GL_BITMAP</tt></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mn>1</mml:mn>
							</mml:math></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mn>1</mml:mn>
							</mml:math></td></tr><tr><td><tt>GL_UNSIGNED_SHORT</tt></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>16</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
								</mml:mrow>
							</mml:math></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mo>(</mml:mo>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>16</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
									<mml:mo>)</mml:mo>
									<mml:mi>c</mml:mi>
								</mml:mrow>
							</mml:math></td></tr><tr><td><tt>GL_SHORT</tt></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>15</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
								</mml:mrow>
							</mml:math></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mo>[</mml:mo>
									<mml:mo>(</mml:mo>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>16</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
									<mml:mo>)</mml:mo>
									<mml:mi>c</mml:mi>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
									<mml:mo>]</mml:mo>
									<mml:mo>/</mml:mo>
									<mml:mn>2</mml:mn>
								</mml:mrow>
							</mml:math></td></tr><tr><td><tt>GL_UNSIGNED_INT</tt></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>32</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
								</mml:mrow>
							</mml:math></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mo>(</mml:mo>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>32</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
									<mml:mo>)</mml:mo>
									<mml:mi>c</mml:mi>
								</mml:mrow>
							</mml:math></td></tr><tr><td><tt>GL_INT</tt></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>31</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
								</mml:mrow>
							</mml:math></td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mrow>
									<mml:mo>[</mml:mo>
									<mml:mo>(</mml:mo>
									<mml:mn>2</mml:mn>
									<mml:mo>&#770;</mml:mo>
									<mml:mn>32</mml:mn>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
									<mml:mo>)</mml:mo>
									<mml:mi>c</mml:mi>
									<mml:mo>-</mml:mo>
									<mml:mn>1</mml:mn>
									<mml:mo>]</mml:mo>
									<mml:mo>/</mml:mo>
									<mml:mn>2</mml:mn>
								</mml:mrow>
							</mml:math></td></tr><tr><td><tt>GL_FLOAT</tt></td><td align="center">none</td><td align="center"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
								<mml:mi>c</mml:mi>
							</mml:math></td></tr></tbody></table></div><p>
			Return values are placed in memory as follows. If <i><tt>format</tt></i> is <tt>GL_COLOR_INDEX</tt>,
			<tt>GL_STENCIL_INDEX</tt>, <tt>GL_DEPTH_COMPONENT</tt>, <tt>GL_RED</tt>,
			<tt>GL_GREEN</tt>, <tt>GL_BLUE</tt>, <tt>GL_ALPHA</tt>, or
			<tt>GL_LUMINANCE</tt>, a single value is returned and the data for the <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>i</mml:mi>
				</mml:math>th pixel in the <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mi>j</mml:mi>
				</mml:math>th row is placed in location <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mo>(</mml:mo>
						<mml:mi>j</mml:mi>
						<mml:mo>)</mml:mo>
						<mml:mi>width</mml:mi>
						<mml:mo>+</mml:mo>
						<mml:mi>i</mml:mi>
					</mml:mrow>
				</mml:math>. <tt>GL_RGB</tt> and <tt>GL_BGR</tt> return three values,
			<tt>GL_RGBA</tt> and <tt>GL_BGRA</tt> return four values, and
			<tt>GL_LUMINANCE_ALPHA</tt> returns two values for each pixel, with all values corresponding to a single
			pixel occupying contiguous space in <i><tt>pixels</tt></i>. Storage parameters set by <tt>glPixelStore</tt>, such as <tt>GL_PACK_LSB_FIRST</tt> and
			<tt>GL_PACK_SWAP_BYTES</tt>, affect the way that data is written into memory. See <tt>glPixelStore</tt> for a description.
		</p></div><div class="refsect1" lang="en"><a name="glReadPixels.3G-notes"/><h2>Notes</h2><p>
			Values for pixels that lie outside the window connected to the current GL context are undefined.
		</p><p>
			If an error is generated, no change is made to the contents of <i><tt>pixels</tt></i>.
		</p></div><div class="refsect1" lang="en"><a name="glReadPixels.3G-errors"/><h2>Errors</h2><p>
			<tt>GL_INVALID_ENUM</tt> is generated if <i><tt>format</tt></i> or <i><tt>type</tt></i> is
			not an accepted value.
		</p><p>
			<tt>GL_INVALID_ENUM</tt> is generated if <i><tt>type</tt></i> is <tt>GL_BITMAP</tt> and
			<i><tt>format</tt></i> is not <tt>GL_COLOR_INDEX</tt> or <tt>GL_STENCIL_INDEX</tt>.
		</p><p>
			<tt>GL_INVALID_VALUE</tt> is generated if either <i><tt>width</tt></i> or
			<i><tt>height</tt></i> is negative.
		</p><p>
			<tt>GL_INVALID_OPERATION</tt> is generated if <i><tt>format</tt></i> is
			<tt>GL_COLOR_INDEX</tt> and the color buffers store RGBA color components.
		</p><p>
			<tt>GL_INVALID_OPERATION</tt> is generated if <i><tt>format</tt></i> is
			<tt>GL_STENCIL_INDEX</tt> and there is no stencil buffer.
		</p><p>
			<tt>GL_INVALID_OPERATION</tt> is generated if <i><tt>format</tt></i> is
			<tt>GL_DEPTH_COMPONENT</tt> and there is no depth buffer.
		</p><p>
			<tt>GL_INVALID_OPERATION</tt> is generated if <tt>glReadPixels</tt> is executed between the
			execution of <a href="glBegin.3G.xml"><tt>glBegin</tt></a> and the corresponding execution of <a href="glBegin.3G.xml"><tt>glEnd</tt></a>.
		</p><p>
			<tt>GL_INVALID_OPERATION</tt> is generated if <i><tt>type</tt></i> is one of
			<tt>GL_UNSIGNED_BYTE_3_3_2</tt>, <tt>GL_UNSIGNED_BYTE_2_3_3_REV</tt>,
			<tt>GL_UNSIGNED_SHORT_5_6_5</tt>, or <tt>GL_UNSIGNED_SHORT_5_6_5_REV</tt> and
			<i><tt>format</tt></i> is not <tt>GL_RGB</tt>.
		</p><p>
			<tt>GL_INVALID_OPERATION</tt> is generated if <i><tt>type</tt></i> is one of
			<tt>GL_UNSIGNED_SHORT_4_4_4_4</tt>, <tt>GL_UNSIGNED_SHORT_4_4_4_4_REV</tt>,
			<tt>GL_UNSIGNED_SHORT_5_5_5_1</tt>, <tt>GL_UNSIGNED_SHORT_1_5_5_5_REV</tt>,
			<tt>GL_UNSIGNED_INT_8_8_8_8</tt>, <tt>GL_UNSIGNED_INT_8_8_8_8_REV</tt>,
			<tt>GL_UNSIGNED_INT_10_10_10_2</tt>, or <tt>GL_UNSIGNED_INT_2_10_10_10_REV</tt> and
			<i><tt>format</tt></i> is neither <tt>GL_RGBA</tt> nor <tt>GL_BGRA</tt>.
		</p><p>
			The formats <tt>GL_BGR</tt>, and <tt>GL_BGRA</tt> and types
			<tt>GL_UNSIGNED_BYTE_3_3_2</tt>, <tt>GL_UNSIGNED_BYTE_2_3_3_REV</tt>,
			<tt>GL_UNSIGNED_SHORT_5_6_5</tt>, <tt>GL_UNSIGNED_SHORT_5_6_5_REV</tt>,
			<tt>GL_UNSIGNED_SHORT_4_4_4_4</tt>, <tt>GL_UNSIGNED_SHORT_4_4_4_4_REV</tt>,
			<tt>GL_UNSIGNED_SHORT_5_5_5_1</tt>, <tt>GL_UNSIGNED_SHORT_1_5_5_5_REV</tt>,
			<tt>GL_UNSIGNED_INT_8_8_8_8</tt>, <tt>GL_UNSIGNED_INT_8_8_8_8_REV</tt>,
			<tt>GL_UNSIGNED_INT_10_10_10_2</tt>, and <tt>GL_UNSIGNED_INT_2_10_10_10_REV</tt> are available
			only if the GL version is 1.2 or greater.
		</p></div><div class="refsect1" lang="en"><a name="glReadPixels.3G-associated_gets"/><h2>Associated Gets</h2><p>
			<tt>glGet</tt> with argument <tt>GL_INDEX_MODE</tt>
		</p></div><div class="refsect1" lang="en"><a name="glReadPixels.3G-see_also"/><h2>See Also</h2><p>
			<span class="simplelist"><a href="glCopyPixels.3G.xml">glCopyPixels</a>, <a href="glDrawPixels.3G.xml">glDrawPixels</a>, <a href="glPixelMap.3G.xml">glPixelMap</a>, <a href="glPixelStore.3G.xml">glPixelStore</a>, <a href="glPixelTransfer.3G.xml">glPixelTransfer</a>, <a href="glReadBuffer.3G.xml">glReadBuffer</a></span>
		</p></div></div><div class="navfooter"><hr/><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="glReadBuffer.3G.xml">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-GL.xml">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="glRect.3G.xml">Next</a></td></tr><tr><td width="40%" align="left" valign="top">glReadBuffer </td><td width="20%" align="center"><a accesskey="h" href="index.xml">Home</a></td><td width="40%" align="right" valign="top"> glRect</td></tr></table></div></body></html>