<?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>gluUnProject4</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.07 Man Pages"/><link rel="up" href="reference-GLU.xml" title="GLU"/><link rel="previous" href="gluUnProject.3G.xml" title="gluUnProject"/><link rel="next" href="reference-GLUT.xml" title="GLUT"/></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">gluUnProject4</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="gluUnProject.3G.xml">Prev</a> </td><th width="60%" align="center">GLU</th><td width="20%" align="right"> <a accesskey="n" href="reference-GLUT.xml">Next</a></td></tr></table><hr/></div><div class="refentry" lang="en"><a name="gluUnProject4.3G"/><div class="titlepage"/><div class="refnamediv"><a name="gluUnProject4.3G-name"/><h2>Name</h2><p>gluUnProject4 &#8212; map window and clip coordinates to object coordinates</p></div><div class="refsynopsisdiv"><a name="gluUnProject4.3G-c_spec"/><h2>C Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code>GLint <tt>gluUnProject4</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code>GLdouble <i><tt>winX</tt></i>, GLdouble <i><tt>winY</tt></i>, GLdouble <i><tt>winZ</tt></i>, GLdouble <i><tt>clipW</tt></i>, const GLdouble *<i><tt>model</tt></i>, const GLdouble *<i><tt>proj</tt></i>, const GLint *<i><tt>view</tt></i>, GLdouble <i><tt>near</tt></i>, GLdouble <i><tt>far</tt></i>, GLdouble* <i><tt>objX</tt></i>, GLdouble* <i><tt>objY</tt></i>, GLdouble* <i><tt>objZ</tt></i>, GLdouble* <i><tt>objW</tt></i>);</code></td></tr></table></div><div class="refsynopsisdiv"><a name="gluUnProject4.3G-python_spec"/><h2>Python Specification</h2><table class="funcprototype" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top"><code><tt>gluUnProject4</tt></code></td><td valign="top"><code>(</code></td><td valign="top"><code><i><tt>winX</tt></i>, <i><tt>winY</tt></i>, <i><tt>winZ</tt></i>, <i><tt>clipW</tt></i>, <i><tt>model</tt></i> = <tt>None</tt>, <i><tt>proj</tt></i> = <tt>None</tt>, <i><tt>view</tt></i> = <tt>None</tt>, <i><tt>near</tt></i> = 0.0, <i><tt>far</tt></i> = 1.0) &#8594; (<i><tt>objX</tt></i>,
				<i><tt>objY</tt></i>,
				<i><tt>objZ</tt></i>,
				<i><tt>objW</tt></i>)</code></td></tr></table></div><div class="refsect1" lang="en"><a name="gluUnProject4.3G-parameters"/><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><i><tt>winX</tt></i>, <i><tt>winY</tt></i>, <i><tt>winZ</tt></i></span></dt><dd>
						Specify the window coordinates to be mapped.
					</dd><dt><span class="term"><i><tt>clipW</tt></i></span></dt><dd>
						Specify the clip w coordinate to be mapped.
					</dd><dt><span class="term"><i><tt>model</tt></i></span></dt><dd>
						Specifies the modelview matrix (as from a <a href="glGet.3G.xml"><tt>glGetDoublev</tt></a> call).
					</dd><dt><span class="term"><i><tt>proj</tt></i></span></dt><dd>
						Specifies the projection matrix (as from a <a href="glGet.3G.xml"><tt>glGetDoublev</tt></a> call).
					</dd><dt><span class="term"><i><tt>view</tt></i></span></dt><dd>
						Specifies the viewport (as from a <a href="glGet.3G.xml"><tt>glGetIntegerv</tt></a> call).
					</dd><dt><span class="term"><i><tt>near</tt></i>, <i><tt>far</tt></i></span></dt><dd>
						Specifies the near and far planes (as from a <a href="glGet.3G.xml"><tt>glGetDoublev</tt></a> call).
					</dd><dt><span class="term"><i><tt>objX</tt></i>, <i><tt>objY</tt></i>, <i><tt>objZ</tt></i>,
				<i><tt>objW</tt></i></span></dt><dd>
						Returns the computed object coordinates.
					</dd></dl></div></div><div class="refsect1" lang="en"><a name="gluUnProject4.3G-description"/><h2>Description</h2><p>
			<tt>gluUnProject4</tt> maps the specified window coordinates <i><tt>winX</tt></i>,
			<i><tt>winY</tt></i> and <i><tt>winZ</tt></i> and its clip w coordinate <i><tt>clipW</tt></i> into
			object coordinates (<i><tt>objX</tt></i>, <i><tt>objY</tt></i>, <i><tt>objZ</tt></i>,
			<i><tt>objW</tt></i>) using <i><tt>model</tt></i>, <i><tt>proj</tt></i> and
			<i><tt>view</tt></i>. <i><tt>clipW</tt></i> can be other than 1 as for vertices in <a href="glFeedbackBuffer.3G.xml"><tt>glFeedbackBuffer</tt></a> when data type <tt>GL_4D_COLOR_TEXTURE</tt> is returned.
			This also handles the case where the <i><tt>near</tt></i> and <i><tt>far</tt></i> planes are different
			from the default, 0 and 1, respectively. A return value of <tt>GL_TRUE</tt> indicates success; a return
			value of <tt>GL_FALSE</tt> indicates failure.
		</p><p>
			To compute the coordinates (<i><tt>objX</tt></i>, <i><tt>objY</tt></i>, <i><tt>objZ</tt></i> and
			<i><tt>objW</tt></i>), <tt>gluUnProject4</tt> multiplies the normalized device coordinates by the
			inverse of <i><tt>model</tt></i>*<i><tt>proj</tt></i> as follows:
		</p><p>
			</p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" mode="display" overflow="scroll">
					<mml:mrow>
						<mml:mrow>
							<mml:mo>(</mml:mo>
							<mml:mtable columnalign="center">
								<mml:mtr>
									<mml:mtd>
										<mml:mi>objX</mml:mi>
									</mml:mtd>
								</mml:mtr>
								<mml:mtr>
									<mml:mtd>
										<mml:mi>objY</mml:mi>
									</mml:mtd>
								</mml:mtr>
								<mml:mtr>
									<mml:mtd>
										<mml:mi>objZ</mml:mi>
									</mml:mtd>
								</mml:mtr>
								<mml:mtr>
									<mml:mtd>
										<mml:mi>objW</mml:mi>
									</mml:mtd>
								</mml:mtr>
							</mml:mtable>
							<mml:mo>)</mml:mo>
						</mml:mrow>
						<mml:mo>=</mml:mo>
						<mml:mi>INV</mml:mi>
						<mml:mo>(</mml:mo>
						<mml:mi>P</mml:mi>
						<mml:mi>M</mml:mi>
						<mml:mo>)</mml:mo>
						<mml:mrow>
							<mml:mo>(</mml:mo>
							<mml:mtable columnalign="center">
								<mml:mtr>
									<mml:mtd>
										<mml:mrow>
											<mml:mfrac>
												<mml:mrow>
													<mml:mn>2</mml:mn>
													<mml:mo>(</mml:mo>
													<mml:mi>winX</mml:mi>
													<mml:mo>-</mml:mo>
													<mml:mi>view</mml:mi>
													<mml:mo>[</mml:mo>
													<mml:mn>0</mml:mn>
													<mml:mo>]</mml:mo>
													<mml:mo>)</mml:mo>
												</mml:mrow>
												<mml:mrow>
													<mml:mi>view</mml:mi>
													<mml:mo>[</mml:mo>
													<mml:mn>2</mml:mn>
													<mml:mo>]</mml:mo>
												</mml:mrow>
											</mml:mfrac>
											<mml:mo>-</mml:mo>
											<mml:mn>1</mml:mn>
										</mml:mrow>
									</mml:mtd>
								</mml:mtr>
								<mml:mtr>
									<mml:mtd>
										<mml:mrow>
											<mml:mfrac>
												<mml:mrow>
													<mml:mn>2</mml:mn>
													<mml:mo>(</mml:mo>
													<mml:mi>winY</mml:mi>
													<mml:mo>-</mml:mo>
													<mml:mi>view</mml:mi>
													<mml:mo>[</mml:mo>
													<mml:mn>1</mml:mn>
													<mml:mo>]</mml:mo>
													<mml:mo>)</mml:mo>
												</mml:mrow>
												<mml:mrow>
													<mml:mi>view</mml:mi>
													<mml:mo>[</mml:mo>
													<mml:mn>3</mml:mn>
													<mml:mo>]</mml:mo>
												</mml:mrow>
											</mml:mfrac>
											<mml:mo>-</mml:mo>
											<mml:mn>1</mml:mn>
										</mml:mrow>
									</mml:mtd>
								</mml:mtr>
								<mml:mtr>
									<mml:mtd>
										<mml:mrow>
											<mml:mfrac>
												<mml:mrow>
													<mml:mn>2</mml:mn>
													<mml:mo>(</mml:mo>
													<mml:mi>winZ</mml:mi>
													<mml:mo>-</mml:mo>
													<mml:mi>near</mml:mi>
													<mml:mo>)</mml:mo>
												</mml:mrow>
												<mml:mrow>
													<mml:mo>(</mml:mo>
													<mml:mi>far</mml:mi>
													<mml:mo>-</mml:mo>
													<mml:mi>near</mml:mi>
													<mml:mo>)</mml:mo>
												</mml:mrow>
											</mml:mfrac>
											<mml:mo>-</mml:mo>
											<mml:mn>1</mml:mn>
										</mml:mrow>
									</mml:mtd>
								</mml:mtr>
								<mml:mtr>
									<mml:mtd>
										<mml:mi>clipW</mml:mi>
									</mml:mtd>
								</mml:mtr>
							</mml:mtable>
							<mml:mo>)</mml:mo>
						</mml:mrow>
					</mml:mrow>
				</mml:math></div><p><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
					<mml:mrow>
						<mml:mi>INV</mml:mi>
						<mml:mo>(</mml:mo>
						<mml:mo>)</mml:mo>
					</mml:mrow>
				</mml:math> denotes matrix inversion.
		</p><p>
			<tt>gluUnProject4</tt> is equivalent to <a href="gluUnProject.3G.xml"><tt>gluUnProject</tt></a> when
			<i><tt>clipW</tt></i> is 1, <i><tt>near</tt></i> is 0 and <i><tt>far</tt></i> is 1.
		</p></div><div class="refsect1" lang="en"><a name="gluUnProject4.3G-notes"/><h2>Notes</h2><p>
			<tt>gluUnProject4</tt> is available only if the GLU version is 1.3 or greater.
		</p></div><div class="refsect1" lang="en"><a name="gluUnProject4.3G-see_also"/><h2>See Also</h2><p>
			<span class="simplelist"><a href="glGet.3G.xml">glGet</a>, <a href="glFeedbackBuffer.3G.xml">glFeedbackBuffer</a>, <a href="gluProject.3G.xml">gluProject</a>, <a href="gluUnProject.3G.xml">gluUnProject</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="gluUnProject.3G.xml">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-GLU.xml">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="reference-GLUT.xml">Next</a></td></tr><tr><td width="40%" align="left" valign="top">gluUnProject </td><td width="20%" align="center"><a accesskey="h" href="index.xml">Home</a></td><td width="40%" align="right" valign="top"> GLUT</td></tr></table></div></body></html>