
<refentry id="glXCreateContext">
    <refmeta>
        <refmetainfo>
            <copyright>
                <year>1991-2006</year>
                <holder>Silicon Graphics, Inc.</holder>
            </copyright>
        </refmetainfo>
        <refentrytitle>glXCreateContext</refentrytitle>
        <manvolnum>3G</manvolnum>
    </refmeta>
    <refnamediv>
        <refname>glXCreateContext</refname>
        <refpurpose>create a new GLX rendering context</refpurpose>
    </refnamediv>
    <refsynopsisdiv><title>C Specification</title>
        <funcsynopsis>
            <funcprototype>
                <funcdef>GLXContext <function>glXCreateContext</function></funcdef>
                <paramdef>Display * <parameter>dpy</parameter></paramdef>
                <paramdef>XVisualInfo * <parameter>vis</parameter></paramdef>
                <paramdef>GLXContext <parameter>shareList</parameter></paramdef>
                <paramdef>Bool <parameter>direct</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>
    <!-- eqn: ignoring delim $$ -->
    <refsect1 id="parameters"><title>Parameters</title>
        <variablelist>
        <varlistentry>
            <term><parameter>dpy</parameter></term>
            <listitem>
                <para>
                    Specifies the connection to the X server.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>vis</parameter></term>
            <listitem>
                <para>
                    Specifies the visual that defines the frame buffer resources available to
                    the rendering context.
                    It is a pointer to an <constant>XVisualInfo</constant> structure,
                    not a visual ID or a pointer to a <constant>Visual</constant>.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>shareList</parameter></term>
            <listitem>
                <para>
                    Specifies the context with which to share display lists.
                    <constant>NULL</constant> indicates that no sharing is to take place.
                </para>
            </listitem>
        </varlistentry>
        <varlistentry>
            <term><parameter>direct</parameter></term>
            <listitem>
                <para>
                    Specifies whether rendering is to be done with a direct connection
                    to the graphics system if possible (<constant>True</constant>)
                    or through the X server (<constant>False</constant>).
                </para>
            </listitem>
        </varlistentry>
        </variablelist>
    </refsect1>
    <refsect1 id="description"><title>Description</title>
        <para>
            <function>glXCreateContext</function> creates a GLX rendering context and returns its handle.
            This context can be used to render into both windows and GLX pixmaps.
            If <function>glXCreateContext</function> fails to create a rendering context,
            <constant>NULL</constant> is returned.
        </para>
        <para>
            If <parameter>direct</parameter> is <constant>True</constant>,
            then a direct rendering context is created if the
            implementation supports direct rendering, if the connection is to an X
            server that is local, and if a direct rendering context is available. (An implementation may return an indirect context when <parameter>direct</parameter> is <constant>True</constant>.)
            If <parameter>direct</parameter> is <constant>False</constant>,
            then a rendering context that renders through the X server is always created.
            Direct rendering provides a performance advantage in some implementations.
            However, direct rendering contexts cannot be shared outside a single process,
            and they may be unable to render to GLX pixmaps.
        </para>
        <para>
            If <parameter>shareList</parameter> is not <constant>NULL</constant>,
            then all display-list indexes and definitions are shared by
            context <parameter>shareList</parameter> and by the newly created context.
            An arbitrary number of contexts can share a single display-list space.
            However,
            all rendering contexts that share a single display-list space must
            themselves exist in the same address space.
            Two rendering contexts share an address space if both are nondirect
            using the same server,
            or if both are direct and owned by a single process.
            Note that in the nondirect case, it is not necessary for the calling
            threads to share an address space,
            only for their related rendering contexts to share an address space.
        </para>
        <para>
            If the GL version is 1.1 or greater, 
            then all texture objects except object 0  
            are shared by any contexts that share display lists.
        </para>
    </refsect1>
    <refsect1 id="notes"><title>Notes</title>
        <para>
            <constant>XVisualInfo</constant> is defined in <emphasis>Xutil.h.</emphasis>
            It is a structure that includes <emphasis>visual</emphasis>, <emphasis>visualID</emphasis>, <emphasis>screen</emphasis>, and
            <emphasis>depth</emphasis> elements.
        </para>
        <para>
            A <emphasis>process</emphasis> is a single execution environment,
            implemented in a single address space,
            consisting of one or more threads.
        </para>
        <para>
            A <emphasis>thread</emphasis> is one of a set of subprocesses that share
            a single address space,
            but maintain separate program counters,
            stack spaces,
            and other related global data.
            A <emphasis>thread</emphasis> that is the only member of its subprocess group
            is equivalent to a <emphasis>process</emphasis>.
        </para>
        <para>
            It may not be possible to render to a GLX pixmap with a direct rendering 
            context.
        </para>
    </refsect1>
    <refsect1 id="errors"><title>Errors</title>
        <para>
            <constant>NULL</constant> is returned if execution fails on the client side.
        </para>
        <para>
            <constant>BadMatch</constant> is generated if the context to be created would not
            share the address space or the screen of the context specified by <parameter>shareList</parameter>.
        </para>
        <para>
            <constant>BadValue</constant> is generated if <parameter>vis</parameter> is not a valid visual (for
            example, if a particular GLX implementation does not support it).
        </para>
        <para>
            <constant>GLXBadContext</constant> is generated if <parameter>shareList</parameter> is not a GLX context
            and is not <constant>NULL</constant>.
        </para>
        <para>
            <constant>BadAlloc</constant> is generated if the server does not have enough
            resources to allocate the new context.
        </para>
    </refsect1>
    <refsect1 id="seealso"><title>See Also</title>
        <para>
            <citerefentry><refentrytitle>glXDestroyContext</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glXGetConfig</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glXIsDirect</refentrytitle></citerefentry>,
            <citerefentry><refentrytitle>glXMakeCurrent</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>
