a
    ij:!                  
   @   s  d Z ddlmZ ddlmZ ddlmZ ddlm	Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lZg dZe
je
je
jdZejree
jdd Zee
jdd Zne
jZe
jZee
jefddZdd Zee
jejZee
j ejZ z[W n& e!y$ Z" zW Y d
Z"["n
d
Z"["0 0 dd Z#e#e
j$ejZ$e#e
j%ejZ%z[#W n& e!yv Z" zW Y d
Z"["n
d
Z"["0 0 dd Z&e
j'e
j(e
j)dZ*dd Z+ee
j,dd Z,dd Z-dd  Z.e
j/e
j0d!Z1d"d# Z2ee
j3d$d% Z3d
S )&z/Exceptional cases that need some extra wrapping    )arrays)GLfloatArray)lazy)GL_1_1)_errors)bytes)_configflags)NULLN)glBeginglCallListsglColorglDeleteTexturesglEndglMap1dglMap1fglMap2dglMap2f
glMaterialglRasterPosglTexParameterglVertexglAreTexturesResident)         c                 C   s   t j  | |S )zCBegin GL geometry-definition mode, disable automatic error checking)r   _error_checkerZonBegin)baseFunctionmode r   S/home/ghrups/robot-bench/.venv/lib/python3.9/site-packages/OpenGL/GL/exceptional.pyr
   $   s    
r
   c                 C   s   t j  |  S )zFFinish GL geometry-definition mode, re-enable automatic error checking)r   r   ZonEnd)r   r   r   r   r   )   s    
r   c                 C   s0   |t u r"tj|}tj|}n|}| ||S )zDelete specified set of textures
    
    If array is *not* passed then `size` must be a `GLuintArray`
    compatible object which can be sized using `arraySize`, the 
    result of which will be used as size.
    )_NULLr   GLuintArrayasArray	arraySize)r   sizearrayptrr   r   r   r   2   s
    r   c                    s     fdd}j |_ |_|S )Nc                    s<     |} |\}}}	|	| }
| |||
||||	||
S )zglMap2(target, u1, u2, v1, v2, points[][][]) -> None

        This is a completely non-standard signature which doesn't allow for most
        of the funky uses with strides and the like, but it has been like this for
        a very long time...
        r"   
dimensions)targetu1u2Zv1Zv2pointsr&   uorderZvorderZvstrideustride	arrayTyper   r   r   glMap2C   s    
zglMap2.<locals>.glMap2__name__r   )r   r0   r1   r   r/   r   r1   B   s    r1   c                    s$    fdd}|j j k |_|S )Nc                    s6     |} |}|d }|d }| |||||S )zglMap1(target, u1, u2, points[][][]) -> None

        This is a completely non-standard signature which doesn't allow for most
        of the funky uses with strides and the like, but it has been like this for
        a very long time...
        r      r'   )r)   r*   r+   r,   r&   dimsr-   r.   r/   r   r   glMap1`   s
    

zglMap1.<locals>.glMap1r2   )r   r0   r6   r   r/   r   r6   _   s    r6   c                  G   s(   t | dkr| d } tt |  }||  S )z+Choose glRasterPosX based on number of argsr4   r   )lenglRasterPosDispatch)argsfunctionr   r   r   r   v   s    r   c                  G   s$   t | dkr| d } tt |  |  S )z(Choose glVertexX based on number of argsr4   r   )r7   glVertexDispatch)r9   r   r   r   r      s    r   c                 G   sv   t |sft|tr2| t |tjttj	|S tj
|}tj
|}| |tjttj
	|S | |g|R  S )zglCallLists( bytes( lists ) or lists[] ) -> None

    Restricted version of glCallLists, takes a string or a GLuint compatible
    array data-type and passes into the base function.
    )r7   
isinstancer   fullZGL_UNSIGNED_BYTEctypesZc_void_pr   ZGLubyteArrayZdataPointerr!   r"   r#   ZGL_UNSIGNED_INT)r   listsr9   r&   r$   r   r   r   r      s    
r   c                 C   sP   t |trt| ||S t |tr0t| ||S t|tj}t	| ||S dS )zLSet a texture parameter, choose underlying call based on pname and parameterN)
r<   floatr=   ZglTexParameterfintZglTexParameterir   r"   ZGL_FLOATZglTexParameterfv)r)   ZpnameZ	parametervaluer   r   r   r      s    

r   c                 G   sV   t |dkr>t|d }|du r0td|f t| ||S tj| |g|R  S dS )zglMaterial -- convenience function to dispatch on argument type

    If passed a single argument in args, calls:
        glMaterialfv( faces, constant, args[0] )
    else calls:
        glMaterialf( faces, constant, *args )
    r4   r   NzNull value in glMaterial: %s)r7   r   r"   
ValueErrorr=   ZglMaterialfvZglMaterialf)ZfacesZconstantr9   argr   r   r   r      s    r   )r   r   c                  G   s   t | }|dkr8tj| d }ttj| }||S |dkrJtj|  S |dkr\tj|  S |dkrntj	|  S t
d| f dS )zglColor*f* -- convenience function to dispatch on argument type

    dispatches to glColor3f, glColor2f, glColor4f, glColor3f, glColor2f, glColor4f
    depending on the arguments passed...
    r4   r   r   r   r   z&Don't know how to handle arguments: %sN)r7   r   r   r"   glColorDispatchr#   r=   Z	glColor2dZ	glColor3dZ	glColor4drC   )r9   ZarglenrD   r:   r   r   r   r      s    


r   c           	      G   sF  t |dkr<|d }tj|}tj|}tj|f}nt |dkrzt|d }W nF ty   |d }tj|}tj|}|d }tj|}Y q0 |d }tj|}tj|f}n8t |dkr|\}}}tj|}tj|}ntdtj	|}tj	|}| |||}|rBt
t |D ]}d||< q2|S )an  Allow both Pythonic and C-style calls to glAreTexturesResident

        glAreTexturesResident( arrays.GLuintArray( textures) )

    or

        glAreTexturesResident( int(n), arrays.GLuintArray( textures), arrays.GLuboolean( output) )

    or

        glAreTexturesResident( int(n), arrays.GLuintArray( textures) )

    returns the output arrays.GLubooleanArray
    r4   r   r   r   z2Expected 1 to 3 arguments to glAreTexturesResident)r7   r   r!   r"   r#   ZGLbooleanArrayZzerosrA   	TypeErrorZtypedPointerrange)	r   r9   ZtexturesnoutputZ
texturePtrZ	outputPtrresultir   r   r   r      s:    
r   )4__doc__ZOpenGLr   ZOpenGL.arrays.arraydatatyper   ZOpenGL.lazywrapperr   Z_lazyZOpenGL.GL.VERSIONr   r=   ZOpenGL.raw.GLr   ZOpenGL._bytesr   r   ZOpenGL._nullr	   r    r>   __all__ZglRasterPos2dZglRasterPos3dZglRasterPos4dr8   ZERROR_CHECKINGr
   r   r   r1   r   ZGLdoubleArrayr   	NameErrorerrr6   r   r   r   Z
glVertex2dZ
glVertex3dZ
glVertex4dr;   r   r   r   r   Z
glColor3fvZ
glColor4fvrE   r   r   r   r   r   r   <module>   sj   
	

