a
    ij                     @   s:   d Z ddlZddlZddlmZmZ G dd dejZdS )z*GLX (x-windows)-specific platform features    N)baseplatformctypesloaderc                   @   s   e Zd ZdZejdd Zejdd Zejdd Zejdd	 Z	ejd
d Z
ejdd Zejdd Zejdd Zejdd Zejdd Zejdd ZeejZejdd Zdd Zejdd ZdS )GLXPlatformz=Posix (Linux, FreeBSD, etceteras) implementation for PyOpenGLc                 C   sd   dD ]R}zt jtj|tjd}W n( tyH } zd }W Y d }~n
d }~0 0 |r|  S qtdd S )N)OpenGLGLmodez#Unable to load OpenGL or GL library)r   loadLibraryctypescdllRTLD_GLOBALOSErrorImportErrorselfnameliberr r   Q/home/ghrups/robot-bench/.venv/lib/python3.9/site-packages/OpenGL/platform/glx.pyr      s    


zGLXPlatform.GLc                 C   s0   zt jtjdtjdW S  ty*   Y d S 0 d S )NGLUr   r   r	   r
   r   r   r   r   r   r   r   r      s    zGLXPlatform.GLUc                 C   s0   zt jtjdtjdW S  ty*   Y d S 0 d S )Nglutr   r   r   r   r   r   GLUT!   s    
zGLXPlatform.GLUTc              
   C   sl   z<dD ]2}t jtj|tjd}|rt|dd r|  W S qW n* tyf } z| jW  Y d }~S d }~0 0 d S )N)GLXr   r   r   ZglXCreateContext)r   r	   r
   r   r   getattrr   r   r   r   r   r   r   *   s    
zGLXPlatform.GLXc                 C   s0   zt jtjdtjdW S  ty*   Y d S 0 d S )NZ	GLESv1_CMr   r   r   r   r   r   GLES16   s    
zGLXPlatform.GLES1c                 C   s0   zt jtjdtjdW S  ty*   Y d S 0 d S )NZGLESv2r   r   r   r   r   r   GLES2?   s    
zGLXPlatform.GLES2c                 C   s   | j S N)r   r   r   r   r   GLES3H   s    zGLXPlatform.GLES3c                 C   s   t tjdS )NEGL)r   r	   r
   r   r   r   r   r   r!   M   s    zGLXPlatform.EGLc                 C   s   | j j}tj|_|S r   )r   glXGetProcAddressARBr
   c_void_prestype)r   baser   r   r   r"   Q   s    z GLXPlatform.glXGetProcAddressARBc                 C   s   | j S r   )r"   r   r   r   r   getExtensionProcedureW   s    z!GLXPlatform.getExtensionProcedurec                 C   s0   zt jtjdtjdW S  ty*   Y d S 0 d S )NZgler   r   r   r   r   r   GLE[   s    zGLXPlatform.GLEc                 C   s   | j j}tj|_|S r   )r   glXGetCurrentContextr
   r#   r$   )r   r(   r   r   r   GetCurrentContextf   s    zGLXPlatform.GetCurrentContextc                 C   sT   dd | ddd D }dddd |D  }tj| j|}tt|S )	a  Platform specific function to retrieve a GLUT font pointer

        GLUTAPI void *glutBitmap9By15;
        #define GLUT_BITMAP_9_BY_15		(&glutBitmap9By15)

        Key here is that we want the addressof the pointer in the DLL,
        not the pointer in the DLL.  That is, our pointer is to the
        pointer defined in the DLL, we don't want the *value* stored in
        that pointer.
        c                 S   s   g | ]}|  qS r   title.0xr   r   r   
<listcomp>w       z2GLXPlatform.getGLUTFontPointer.<locals>.<listcomp>_   Nr    c                 S   s   g | ]}|  qS r   r*   r,   r   r   r   r/   x   r0   )splitjoinr
   r#   Zin_dllr   Z	addressof)r   Zconstantr   ZinternalZpointerr   r   r   getGLUTFontPointerl   s    zGLXPlatform.getGLUTFontPointerc                 C   s   | j jS r   )r   
glGetErrorr   r   r   r   r7   |   s    zGLXPlatform.glGetErrorN)__name__
__module____qualname____doc__r   Zlazy_propertyr   r   r   r   r   r   r    r!   r"   r&   r'   staticmethodr
   Z	CFUNCTYPEZDEFAULT_FUNCTION_TYPEr)   r6   r7   r   r   r   r   r      s:   












r   )r;   r
   Zctypes.utilZOpenGL.platformr   r   ZBasePlatformr   r   r   r   r   <module>   s   