a
    i‚j?	  ã                   @   sF   d Z ddlZddlZddlZddlmZ ejZejZ	G dd„ dƒZ
dS )z6An Apple CGL context for offscreen rendering on macOS.é    N)Úcglc                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )Ú	GLContextzHAn EGL context for headless accelerated OpenGL rendering on GPU devices.c                 C   s¤   ~~t jtjt jdt jdt jdt jdt jt j	dt j
dt jdf}tjt|ƒ |Ž }t ¡ | _t ¡ }t |t | j¡t |¡¡ t ¡ | _t | jdt | j¡¡ d S )Né   é   é   é   r   )Ú_ATTRIBZCGLPFAOpenGLProfileÚ_PROFILEZCGLOGLPVersion_LegacyZCGLPFAColorSizeZCGLPFAAlphaSizeZCGLPFADepthSizeZCGLPFAStencilSizeZCGLPFAMultisampleZCGLPFASampleBuffersZCGLPFASampleZCGLPFAAcceleratedÚctypesZc_intÚlenr   ZCGLPixelFormatObjÚ_pixZGLintZCGLChoosePixelFormatZbyrefZCGLContextObjÚ_contextZCGLCreateContext)ÚselfÚ	max_widthÚ
max_heightZattrib_valuesÚattribsZnpix© r   úS/home/ghrups/robot-bench/.venv/lib64/python3.9/site-packages/mujoco/cgl/__init__.pyÚ__init__   s(    ö
ÿ
zGLContext.__init__c                 C   s   t  | j¡ t  | j¡ d S ©N)r   ÚCGLSetCurrentContextr   ZCGLLockContext©r   r   r   r   Úmake_current6   s    zGLContext.make_currentc                 C   sb   zJ| j r*t | j ¡ t d¡ t | j ¡ d| _ | jrBt | j¡ d| _W n ty\   Y n0 dS )z-Frees resources associated with this context.N)r   r   ZCGLUnlockContextr   ZCGLReleaseContextr   ZCGLReleasePixelFormatÚ	Exceptionr   r   r   r   Úfree:   s    

zGLContext.freec                 C   s   |   ¡  d S r   )r   r   r   r   r   Ú__del__I   s    zGLContext.__del__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s
   r   )r   Úatexitr
   ÚosZ
mujoco.cglr   ZCGLPixelFormatAttributer   ZCGLOpenGLProfiler	   r   r   r   r   r   Ú<module>   s   