<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "xhtml1-transitional.dtd">
<!-- saved from url=(0013)about:internet -->
<?xml-stylesheet type="text/xsl" href="mathml.xsl"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:pref="http://www.w3.org/2002/Math/preference" pref:renderer="mathplayer-dl"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>gluUnProject4</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /></head><body><div class="refentry" lang="en" xml:lang="en"><a id="gluUnProject4"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>gluUnProject4 — map window and clip coordinates to object coordinates</p></div><div class="refsynopsisdiv"><h2>C Specification</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0"><tr><td><code class="funcdef">GLint <b class="fsfunc">gluUnProject4</b>(</code></td><td>GLdouble  </td><td><var class="pdparam">winX</var>, </td></tr><tr><td> </td><td>GLdouble  </td><td><var class="pdparam">winY</var>, </td></tr><tr><td> </td><td>GLdouble  </td><td><var class="pdparam">winZ</var>, </td></tr><tr><td> </td><td>GLdouble  </td><td><var class="pdparam">clipW</var>, </td></tr><tr><td> </td><td>const GLdouble *  </td><td><var class="pdparam">model</var>, </td></tr><tr><td> </td><td>const GLdouble *  </td><td><var class="pdparam">proj</var>, </td></tr><tr><td> </td><td>const GLint *  </td><td><var class="pdparam">view</var>, </td></tr><tr><td> </td><td>GLdouble  </td><td><var class="pdparam">nearVal</var>, </td></tr><tr><td> </td><td>GLdouble  </td><td><var class="pdparam">farVal</var>, </td></tr><tr><td> </td><td>GLdouble*  </td><td><var class="pdparam">objX</var>, </td></tr><tr><td> </td><td>GLdouble*  </td><td><var class="pdparam">objY</var>, </td></tr><tr><td> </td><td>GLdouble*  </td><td><var class="pdparam">objZ</var>, </td></tr><tr><td> </td><td>GLdouble*  </td><td><var class="pdparam">objW</var><code>)</code>;</td></tr></table></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="parameters"></a><h2>Parameters</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>winX</code></em>, </span><span class="term"><em class="parameter"><code>winY</code></em>, </span><span class="term"><em class="parameter"><code>winZ</code></em></span></dt><dd><p>
                    Specify the window coordinates to be mapped.
                </p></dd><dt><span class="term"><em class="parameter"><code>clipW</code></em></span></dt><dd><p>
                    Specify the clip w coordinate to be mapped.
                </p></dd><dt><span class="term"><em class="parameter"><code>model</code></em></span></dt><dd><p>
                    Specifies the modelview matrix (as from a <a class="citerefentry" href="glGetDoublev.xml"><span class="citerefentry"><span class="refentrytitle">glGetDoublev</span></span></a> call).
                </p></dd><dt><span class="term"><em class="parameter"><code>proj</code></em></span></dt><dd><p>
                    Specifies the projection matrix (as from a <a class="citerefentry" href="glGetDoublev.xml"><span class="citerefentry"><span class="refentrytitle">glGetDoublev</span></span></a> call).
                </p></dd><dt><span class="term"><em class="parameter"><code>view</code></em></span></dt><dd><p>
                    Specifies the viewport (as from a <a class="citerefentry" href="glGetIntegerv.xml"><span class="citerefentry"><span class="refentrytitle">glGetIntegerv</span></span></a> call).
                </p></dd><dt><span class="term"><em class="parameter"><code>nearVal</code></em>, </span><span class="term"><em class="parameter"><code>farVal</code></em></span></dt><dd><p>
                    Specifies the near and far planes (as from a <a class="citerefentry" href="glGetDoublev.xml"><span class="citerefentry"><span class="refentrytitle">glGetDoublev</span></span></a> call).
                </p></dd><dt><span class="term"><em class="parameter"><code>objX</code></em>, </span><span class="term"><em class="parameter"><code>objY</code></em>, </span><span class="term"><em class="parameter"><code>objZ</code></em>, </span><span class="term"><em class="parameter"><code>objW</code></em></span></dt><dd><p>
                    Returns the computed object coordinates.
                </p></dd></dl></div></div><div class="refsect1" lang="en" xml:lang="en"><a id="description"></a><h2>Description</h2><p>
            <code class="function">gluUnProject4</code> maps the specified window coordinatesi: <em class="parameter"><code>winX</code></em>, <em class="parameter"><code>winY</code></em>, and <em class="parameter"><code>winZ</code></em>
            and its clip w coordinate <em class="parameter"><code>clipW</code></em>
            into object 
            coordinates 
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                
                <mml:mfenced open="(" close=")">
                    <mml:mi mathvariant="italic">objX</mml:mi>
                    <mml:mi mathvariant="italic">objY</mml:mi>
                    <mml:mi mathvariant="italic">objZ</mml:mi>
                    <mml:mi mathvariant="italic">objW</mml:mi>
                </mml:mfenced>
            </mml:math>
            using <em class="parameter"><code>model</code></em>, <em class="parameter"><code>proj</code></em>, and <em class="parameter"><code>view</code></em>. <em class="parameter"><code>clipW</code></em> can be other than
            1 as for vertices in <a class="citerefentry" href="glFeedbackBuffer.xml"><span class="citerefentry"><span class="refentrytitle">glFeedbackBuffer</span></span></a> when data type 
            <code class="constant">GLU_4D_COLOR_TEXTURE</code> is returned.
            This also handles the case
            where the <em class="parameter"><code>nearVal</code></em> and <em class="parameter"><code>farVal</code></em> planes are different from the default,
            0 and 1, respectively.
            A return 
            value of <code class="constant">GLU_TRUE</code> indicates success; a return value of <code class="constant">GLU_FALSE</code>
            indicates failure.
        </p><p>
            To compute the coordinates 
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                
                <mml:mfenced open="(" close=")">
                    <mml:mi mathvariant="italic">objX</mml:mi>
                    <mml:mi mathvariant="italic">objY</mml:mi>
                    <mml:mi mathvariant="italic">objZ</mml:mi>
                    <mml:mi mathvariant="italic">objW</mml:mi>
                </mml:mfenced>
            </mml:math>,
            <code class="function">gluUnProject4</code> multiplies the normalized device coordinates by the inverse of
            <em class="parameter"><code>model</code></em> * <em class="parameter"><code>proj</code></em> as follows:
        </p><p>
            </p><div class="informalequation"><mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll">
                
                <mml:mrow>
                    <mml:mfenced open="(" close=")">
                        <mml:mtable>
                            <mml:mtr><mml:mtd>
                                <mml:mi mathvariant="italic">objX</mml:mi>
                            </mml:mtd></mml:mtr>
                            <mml:mtr><mml:mtd>
                                <mml:mi mathvariant="italic">objY</mml:mi>
                            </mml:mtd></mml:mtr>
                            <mml:mtr><mml:mtd>
                                <mml:mi mathvariant="italic">objZ</mml:mi>
                            </mml:mtd></mml:mtr>
                            <mml:mtr><mml:mtd>
                                <mml:mi mathvariant="italic">objW</mml:mi>
                            </mml:mtd></mml:mtr>
                        </mml:mtable>
                    </mml:mfenced>
                    <mml:mo>=</mml:mo>
                    <mml:mrow>
                        <mml:mrow>
                            <mml:mi mathvariant="italic">INV</mml:mi>
                            <mml:mo>⁡</mml:mo>
                            <mml:mfenced open="(" close=")">
                                <mml:mrow>
                                    <mml:mi mathvariant="italic">P</mml:mi>
                                    <mml:mo>⁢</mml:mo>
                                    <mml:mi mathvariant="italic">M</mml:mi>
                                </mml:mrow>
                            </mml:mfenced>
                        </mml:mrow>
                        <mml:mo>⁢</mml:mo>
                        <mml:mfenced open="(" close=")">
                            <mml:mtable>
                                <mml:mtr><mml:mtd>
                                    <mml:mrow>
                                        <mml:mfrac>
                                            <mml:mfenced open="" close="">
                                                <mml:mrow>
                                                    <mml:mn>2</mml:mn>
                                                    <mml:mo>⁡</mml:mo>
                                                    <mml:mfenced open="(" close=")">
                                                        <mml:mrow>
                                                            <mml:mi mathvariant="italic">winX</mml:mi>
                                                            <mml:mo>-</mml:mo>
                                                            <mml:mrow>
                                                                <mml:mi mathvariant="italic">view</mml:mi>
                                                                <mml:mo>⁡</mml:mo>
                                                                <mml:mfenced open="[" close="]">
                                                                    <mml:mn>0</mml:mn>
                                                                </mml:mfenced>
                                                            </mml:mrow>
                                                        </mml:mrow>
                                                    </mml:mfenced>
                                                </mml:mrow>
                                            </mml:mfenced>
                                            <mml:mfenced open="" close="">
                                                <mml:mrow>
                                                    <mml:mi mathvariant="italic">view</mml:mi>
                                                    <mml:mo>⁡</mml:mo>
                                                    <mml:mfenced open="[" close="]">
                                                        <mml:mn>2</mml:mn>
                                                    </mml:mfenced>
                                                </mml:mrow>
                                            </mml:mfenced>
                                        </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:mfenced open="" close="">
                                                <mml:mrow>
                                                    <mml:mn>2</mml:mn>
                                                    <mml:mo>⁡</mml:mo>
                                                    <mml:mfenced open="(" close=")">
                                                        <mml:mrow>
                                                            <mml:mi mathvariant="italic">winY</mml:mi>
                                                            <mml:mo>-</mml:mo>
                                                            <mml:mrow>
                                                                <mml:mi mathvariant="italic">view</mml:mi>
                                                                <mml:mo>⁡</mml:mo>
                                                                <mml:mfenced open="[" close="]">
                                                                    <mml:mn>1</mml:mn>
                                                                </mml:mfenced>
                                                            </mml:mrow>
                                                        </mml:mrow>
                                                    </mml:mfenced>
                                                </mml:mrow>
                                            </mml:mfenced>
                                            <mml:mfenced open="" close="">
                                                <mml:mrow>
                                                    <mml:mi mathvariant="italic">view</mml:mi>
                                                    <mml:mo>⁡</mml:mo>
                                                    <mml:mfenced open="[" close="]">
                                                        <mml:mn>3</mml:mn>
                                                    </mml:mfenced>
                                                </mml:mrow>
                                            </mml:mfenced>
                                        </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:mfenced open="" close="">
                                                <mml:mrow>
                                                    <mml:mn>2</mml:mn>
                                                    <mml:mo>⁡</mml:mo>
                                                    <mml:mfenced open="(" close=")">
                                                        <mml:mrow>
                                                            <mml:mi mathvariant="italic">winZ</mml:mi>
                                                            <mml:mo>-</mml:mo>
                                                            <mml:mi mathvariant="italic">nearVal</mml:mi>
                                                        </mml:mrow>
                                                    </mml:mfenced>
                                                </mml:mrow>
                                            </mml:mfenced>
                                            <mml:mfenced open="" close="">
                                                <mml:mfenced open="(" close=")">
                                                    <mml:mrow>
                                                        <mml:mi mathvariant="italic">farVal</mml:mi>
                                                        <mml:mo>-</mml:mo>
                                                        <mml:mi mathvariant="italic">nearVal</mml:mi>
                                                    </mml:mrow>
                                                </mml:mfenced>
                                            </mml:mfenced>
                                        </mml:mfrac>
                                        <mml:mo>-</mml:mo>
                                        <mml:mn>1</mml:mn>
                                    </mml:mrow>
                                </mml:mtd></mml:mtr>
                                <mml:mtr><mml:mtd>
                                    <mml:mi mathvariant="italic">clipW</mml:mi>
                                </mml:mtd></mml:mtr>
                            </mml:mtable>
                        </mml:mfenced>
                    </mml:mrow>
                </mml:mrow>
            </mml:math></div><p>
        </p><p>
            <mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML" overflow="scroll"><mml:mi mathvariant="italic">INV</mml:mi></mml:math>
            denotes matrix inversion. 
        </p><p>
            <code class="function">gluUnProject4</code> is equivalent to <a class="citerefentry" href="gluUnProject.xml"><span class="citerefentry"><span class="refentrytitle">gluUnProject</span></span></a> when <em class="parameter"><code>clipW</code></em> is 1, <em class="parameter"><code>nearVal</code></em> is 0, and
            <em class="parameter"><code>farVal</code></em> is 1.
        </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="notes"></a><h2>Notes</h2><p>
            <code class="function">gluUnProject4</code> is available only if the GLU version is 1.3 or greater.
        </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="seealso"></a><h2>See Also</h2><p>
            <a class="citerefentry" href="gluProject.xml"><span class="citerefentry"><span class="refentrytitle">gluProject</span></span></a>,
            <a class="citerefentry" href="gluUnProject.xml"><span class="citerefentry"><span class="refentrytitle">gluUnProject</span></span></a>,
            <a class="citerefentry" href="glFeedbackBuffer.xml"><span class="citerefentry"><span class="refentrytitle">glFeedbackBuffer</span></span></a>,
            <a class="citerefentry" href="glGet.xml"><span class="citerefentry"><span class="refentrytitle">glGet</span></span></a>
        </p></div><div class="refsect1" lang="en" xml:lang="en"><a id="Copyright"></a><h2>Copyright</h2><p>
            Copyright <span class="trademark"></span>© 1991-2006
            Silicon Graphics, Inc. This document is licensed under the SGI
            Free Software B License. For details, see
            <a class="ulink" href="http://oss.sgi.com/projects/FreeB/" target="_top">http://oss.sgi.com/projects/FreeB/</a>.
        </p></div></div></body></html>
