
    \
j                         d Z ddlmZmZ ddlZddlmZmZmZm	Z	m
Z
mZmZ ddlmZ  G d d          Z e            Zej        Zej        Zej        Zej        Zej        Zej        Zej        Zej        Zd ZdS )	a  Information about version and extensions of current GL implementation.

Usage::
    
    from pyglet.gl import gl_info

    if gl_info.have_extension('GL_NV_register_combiners'):
        # ...

If you are using more than one context, you can set up a separate GLInfo
object for each context.  Call `set_active_context` after switching to the
context::

    from pyglet.gl.gl_info import GLInfo

    info = GLInfo()
    info.set_active_context()

    if info.have_version(2, 1):
        # ...

    )c_char_pcastN)GL_EXTENSIONSGL_RENDERER	GL_VENDOR
GL_VERSIONGLintglGetIntegervglGetString)asstrc                   l    e Zd ZdZdZdZdZdZ e            Z	dZ
d Zd Zd Zd Zd	 ZddZd Zd ZdS )GLInfoay  Information interface for a single GL context.

    A default instance is created automatically when the first OpenGL context
    is created.  You can use the module functions as a convenience for
    this default instance's methods.

    If you are using more than one context, you must call `set_active_context`
    when the context is active for this `GLInfo` instance.
    Fz0.0.0 c                 N   d| _         | j        st          t          t	          t
                    t                    j                  | _        t          t          t	          t                    t                    j                  | _
        t          t          t	          t                    t                    j                  | _        |                     d          rLddlmm} t#                      }t%          ||           fdt'          |j                  D             | _        nPt          t          t	          t*                    t                    j                                                  | _        | j        rt/          | j                  | _        d| _        dS dS )zStore information for the currently active context.

        This method is called automatically for the default context.
        T   r   )glGetStringiGL_NUM_EXTENSIONSc           	   3      K   | ]:}t          t           t          |          t                    j                  V  ;d S )N)r   r   r   r   value).0ir   s     K/DATA/AppData/hermes/venv/lib/python3.11/site-packages/pyglet/gl/gl_info.py	<genexpr>z,GLInfo.set_active_context.<locals>.<genexpr>b   s`       #I #I'( $)ll=!.L.Lh)W)W)]#^#^ #I #I #I #I #I #I    N)have_context
_have_infor   r   r   r   r   r   vendorr   rendererr   versionhave_versionpyglet.gl.glext_arbr   r   r	   r
   range
extensionsr   splitset)selfr   num_extensionsr   s      @r   set_active_contextzGLInfo.set_active_contextT   sl   
 ! 	#[%;%;X F F LMMDK!${;'?'?"J"J"PQQDM k*&=&=x!H!H!NOODL  ## bOOOOOOOO!&/@@@#I #I #I #I,1.2F,G,G#I #I #I #([-G-G(R(R(X"Y"Y"_"_"a"a 7"%do"6"6"DOOO	# 	#r   c                 "    d| _         d| _        d S )NF)r   r   r&   s    r   remove_active_contextzGLInfo.remove_active_contextj   s    !r   c                 J    | j         st          j        d           || j        v S )a(  Determine if an OpenGL extension is available.

        :Parameters:
            `extension` : str
                The name of the extension to test for, including its
                ``GL_`` prefix.

        :return: True if the extension is provided by the driver.
        :rtype: bool
        No GL context created yet.r   warningswarnr#   )r&   	extensions     r   have_extensionzGLInfo.have_extensionn   s-       	8M6777DO++r   c                 F    | j         st          j        d           | j        S )zGet a list of available OpenGL extensions.

        :return: a list of the available extensions.
        :rtype: list of str
        r-   r.   r*   s    r   get_extensionszGLInfo.get_extensions}   s(       	8M6777r   c                 F    | j         st          j        d           | j        S )zaGet the current OpenGL version.

        :return: the OpenGL version
        :rtype: str
        r-   )r   r/   r0   r   r*   s    r   get_versionzGLInfo.get_version   s(       	8M6777|r   r   c                 \   | j         st          j        d           | j        r	d| j        v rdS d| j                                                            dd          d         z  }d |                    d	d
          dd
         D             \  }}}||k    p||k    o||k    p||k    o||k    S )a  Determine if a version of OpenGL is supported.

        :Parameters:
            `major` : int
                The major revision number (typically 1 or 2).
            `minor` : int
                The minor revision number.
            `release` : int
                The release number.
                :deprecated: No longer used

        :rtype: bool
        :return: True if the requested or a later version is supported.
        r-   NoneFz%s.0.0    r   c                 ,    g | ]}t          |          S  )int)r   vs     r   
<listcomp>z'GLInfo.have_version.<locals>.<listcomp>   s    #J#J#JqCFF#J#J#Jr   .r   N)r   r/   r0   r   stripr$   )r&   majorminorreleaseverimajoriminorireleases           r   r    zGLInfo.have_version   s        	8M6777| 	v555++--33C;;A>>#J#JCIIc14E4Ebqb4I#J#J#J  654Vu_654Vu_	7r   c                 F    | j         st          j        d           | j        S )zRDetermine the renderer string of the OpenGL context.

        :rtype: str
        r-   )r   r/   r0   r   r*   s    r   get_rendererzGLInfo.get_renderer   s(    
   	8M6777}r   c                 F    | j         st          j        d           | j        S )zPDetermine the vendor string of the OpenGL context.

        :rtype: str
        r-   )r   r/   r0   r   r*   s    r   
get_vendorzGLInfo.get_vendor   s(    
   	8M6777{r   N)r   r   )__name__
__module____qualname____doc__r   r   r   r   r%   r#   r   r(   r+   r2   r4   r6   r    rJ   rL   r<   r   r   r   r   B   s          LGFHJJ# # #,     , , ,    7 7 7 74      r   r   c                      t           j        S )zNDetermine if a default OpenGL context has been set yet.

    :rtype: bool
    )_gl_infor   r<   r   r   r   r      s    
   r   )rP   ctypesr   r   r/   pyglet.gl.glr   r   r   r   r	   r
   r   pyglet.utilr   r   rR   r(   r+   r2   r4   r6   r    rJ   rL   r   r<   r   r   <module>rV      s  H . " ! ! ! ! ! ! !  m m m m m m m m m m m m m m m m m m      y y y y y y y y| 6880  6 (("$$ 
! ! ! ! !r   