a
    ij E  ć                
   @   s¾  d Z ddlmZmZmZ ddlmZmZ ddlZddlm	Z	m
Z
 ddlT ddlmZ dd	 Ze e” d
d”Ze e”jddddjddd dddjddddjddddZe e”jddddjddd dddjddddjddddZe e”jdddd dd”Ze e”jde
jdddZe e”jddd dddjddddZe e”jde
jdddZe e”jddd dddjddddZe e”jddddjddd dddZe e”jdd ddZe e”jdd ddZe e”jdd ddZe e”jd!dddZe e” dd” d"d”Ze e” d#d”Ze e ” d#d”Z e e!” d#d”Z!e e"” d#d”Z"e e#” d#d”Z#e e$” d#d”Z$e e%” d#d”Z%e e&” d#d”Z&e e'” d#d”Z'e e(” d#d”Z(e e)” d#d”Z)e e*” d$d%”Z*e e+” d$d%”Z+e e,” d$d%”Z,e e-” d$d&”Z-e e.” d$d&”Z.e e/” d$d&”Z/e e0” d$d'”Z0e e1” d$d'”Z1e e2” d$d'”Z2e e3” d$d(”Z3e e4” d$d(”Z4e e5” d$d(”Z5e e6” d$d(”Z6e e7” d$d(”Z7e e8” d$d(”Z8e e9” d$d(”Z9e e:” d$d(”Z:e e;” d$d(”Z;e e<” d$d(”Z<e e=” d$d(”Z=e e>” d$d(”Z>e e?” d$d(”Z?e e@” d$d(”Z@ddlZdd)lmAZA dd*lBmCZCmDZDmEZE dd+lFmGZH dd,lFmIZJ dd-lFmKZL dd.lFmMZN dd/lOmPZQ dd0lmRZR dd1lmSZSmTZTmUZU dd2lVmWZWmXZX e Yd3d4”ZZej[d5ej\j]de	j^e	j_e `eja”ejbfd6d7ed8ZeSjcd"d9Zde e” ed” ed” ed"edjf” gd"edjh” ided” idedjj”Zz[dW n& ekyŌ Zl zW Y dZl[ln
dZl[l0 0 eQedRd:d;Zd<d= ZmeAjnremeHeo_peAjnremeJeq_peQed>d? ZeQed@dA ZeQedBdC ZeQedDdE ZeQedSdFdGZeQedTdHdIZeQerdJdK ZreQesdLdM ZseQetdNdO ZteQedUdPdQZdS )Va  OpenGL extension VERSION.GL_2_0

This module customises the behaviour of the 
OpenGL.raw.GL.VERSION.GL_2_0 to provide a more 
Python-friendly API

The official definition of this extension is available here:
http://www.opengl.org/registry/specs/VERSION/GL_2_0.txt
é    )ŚplatformŚconstantŚarrays)Ś
extensionsŚwrapperN)Ś_typesŚ_glgets)Ś*)Ś_EXTENSION_NAMEc                  C   s   ddl m}  |  t”S )z=Return boolean indicating whether this extension is availabler   ©r   )ŚOpenGLr   ZhasGLExtensionr
   r   © r   śV/home/ghrups/robot-bench/.venv/lib/python3.9/site-packages/OpenGL/GL/VERSION/GL_2_0.pyŚglInitGl20VERSION   s    r   ŚbufsŚlength©é   T)ŚsizeŚorPassInŚnamec                 C   s   | fS ©Nr   ©Śxr   r   r   Ś<lambda>   ó    r   ŚbufSize)r   ZpnameArgr   r   Śtypec                 C   s   | fS r   r   r   r   r   r   r   &   r   ŚcountZshadersŚparamsŚpnameZinfoLogc                 C   s   | fS r   r   r   r   r   r   r   7   r   c                 C   s   | fS r   r   r   r   r   r   r   ?   r   Śsourcec                 C   s   | fS r   r   r   r   r   r   r   F   r   )é   ŚpointerŚstringŚvalueŚvr   é   é   r"   )Ś_configflags)ŚbytesŚ_NULL_8_BYTEŚas_8_bit)ŚGL_OBJECT_COMPILE_STATUS_ARB)ŚGL_OBJECT_LINK_STATUS_ARB)ŚGL_OBJECT_ACTIVE_UNIFORMS_ARB)Ś'GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB)Ślazy)Ś_errors)Ś
convertersŚerrorŚcontextdata)ŚArrayDatatypeŚGLenumArrayŚGL_INFO_LOG_LENGTHi  ŚglShaderSourcez@glShaderSource( GLhandle(shaderObj),[bytes(string),...]) -> None)Z	shaderObjr   r$   r   )ZdllZ
resultTypeZargTypesŚdocZargNamesŚ	extension)r   c                 C   sD   |du r0t j d”}d|d< | ||| |d S | ||| |S dS )aM  Retrieve the integer parameter for the given shader

    shader -- shader ID to query
    pname -- parameter name
    status -- pointer to integer to receive status or None to
        return the parameter as an integer value

    returns
        integer if status parameter is None
        status if status parameter is not None
    Nr   r   r   )r   Ś
GLintArrayŚzeros)ŚbaseOperationZshaderr    Śstatusr   r   r   ŚglGetShaderiv  s    r@   c                    s&   t krt nt d fdd	}|S )z>Generate an error-checking function for compilation operationsNc                    s^   t jj| ||g|¢R  } t ” } |d t |” |j}|sZtj| ||t	|d d| S )Nr   )Śresultr>   Ś
cArgumentsŚdescription)
r2   Z_error_checkerZglCheckErrorŚctypesZc_intZbyrefr%   r4   ZGLErrorŚglGetShaderInfoLog)rA   r>   rB   Śargsr?   ©ŚgetterŚkeyr   r   ŚGLSLCheckError4  s     ’’
üz#_afterCheck.<locals>.GLSLCheckError)NN)ŚGL_OBJECT_COMPILE_STATUSr@   ŚglGetProgramiv)rI   rJ   r   rG   r   Ś_afterCheck-  s
    rM   c                 C   s>   t t|t}|dkr:t |”}| ||d| |j t”S dS )zjRetrieve the shader's error messages as a Python string

    returns string which is '' if no message
    r   NŚ )Śintr@   r8   rD   Ścreate_string_bufferr%   Śstripr+   ©r>   Śobjr   Ślogr   r   r   rE   P  s    
rE   c                 C   s>   t t|t}|dkr:t |”}| ||d| |j t”S dS )zrRetrieve the shader program's error messages as a Python string

    returns string which is '' if no message
    r   NrN   )rO   rL   r8   rD   rP   r%   rQ   r+   rR   r   r   r   ŚglGetProgramInfoLog^  s    
rU   c                 C   s>   t |t}|dkr2tj |f”}| ||d| |S tj d”S )z?Retrieve the attached objects as an array of GLhandle instancesr   N)r   )rL   ZGL_ATTACHED_SHADERSr   ZGLuintArrayr=   )r>   rS   r   Zstorager   r   r   ŚglGetAttachedShadersl  s    
rV   c                 C   s>   t t|t}|dkr:t |”}| ||d| |j t”S dS )zsRetrieve the program/shader's source code as a Python string

    returns string which is '' if no source code
    r   NrN   )rO   r@   ZGL_SHADER_SOURCE_LENGTHrD   rP   r%   rQ   r+   )r>   rS   r   r!   r   r   r   ŚglGetShaderSourcew  s    
rW   c                 G   s   |du rt t|t}|dkr(tdt| |||g|¢R  dd \}}}t|drd| ”  d”}n*t|dr~| ”  d”}nt|dr|j	}|||fS )	aČ  Retrieves information about the attribute variable.

    program -- specifies the program to be queried
    index -- index of the attribute to be queried

    Following parameters are optional:

    bufSize -- determines the size of the buffer (limits number of bytes written),
               if not provided, will be GL_ACTIVE_ATTRIBUTE_MAX_LENGTH
    length -- pointer-to-GLsizei that will hold the resulting length of the name
    size -- pointer-to-GLint that will hold the size of the attribute
    type -- pointer-to-GLenum that will hold the type constant of the attribute
    name -- pointer-to-GLchar that will hold the (null-terminated) name string

    returns (bytes) name, (int)size, (enum)type
    Nr   z Active attribute length reportedr   Śtobytesó    Śtostringr%   )
rO   rL   ZGL_ACTIVE_ATTRIBUTE_MAX_LENGTHŚRuntimeErrorŚbufsizeŚhasattrrX   ŚrstriprZ   r%   )r>   ŚprogramŚindexr   rF   r   r   r   r   r   r   ŚglGetActiveAttrib  s    
"


ra   c           
      G   s¶   t t|t}|du r$t t|t}||k r|dkr| |||g|¢R  \}}}}	t|drj| ”  d”}n*t|dr| ”  d”}nt|dr|j}|||	fS t	d||d f dS )	ać  Retrieve the name, size and type of the uniform of the index in the program

    program -- specifies the program to be queried
    index -- index of the uniform to be queried

    Following parameters are optional:

    bufSize -- determines the size of the buffer (limits number of bytes written),
               if not provided, will be GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH
    length -- pointer-to-GLsizei that will hold the resulting length of the name
    size -- pointer-to-GLint that will hold the size of the attribute
    type -- pointer-to-GLenum that will hold the type constant of the attribute
    name -- pointer-to-GLchar that will hold the (null-terminated) name string

    returns (bytes) name, (int)size, (enum)type
    Nr   rX   rY   rZ   r%   zIndex %s out of range 0 to %ir   )
rO   rL   ZGL_ACTIVE_UNIFORMSZGL_ACTIVE_UNIFORM_MAX_LENGTHr]   rX   r^   rZ   r%   Ś
IndexError)
r>   r_   r`   r   rF   Z	max_indexr   r   r   r   r   r   r   ŚglGetActiveUniform„  s&    



ž’’rc   c                 C   s2   |st dt|}|d tkr(|t }| ||S ©z=Check that name is a string with a null byte at the end of itzNon-null name requiredé’’’’©Ś
ValueErrorr,   r+   ©r>   r_   r   r   r   r   ŚglGetUniformLocationĢ  s    ri   c                 C   s2   |st dt|}|d tkr(|t }| ||S rd   rf   rh   r   r   r   ŚglGetAttribLocation×  s    rj   c           	   	   C   s8   t  ||”}d|f}t ||” | |||||t  |”S )aU  Set an attribute pointer for a given shader (index)

    index -- the index of the generic vertex to bind, see
        glGetAttribLocation for retrieval of the value,
        note that index is a global variable, not per-shader
    size -- number of basic elements per record, 1,2,3, or 4
    type -- enum constant for data-type
    normalized -- whether to perform int to float
        normalization on integer-type values
    stride -- stride in machine units (bytes) between
        consecutive records, normally used to create
        "interleaved" arrays
    pointer -- data-pointer which provides the data-values,
        normally a vertex-buffer-object or offset into the
        same.

    This implementation stores a copy of the data-pointer
    in the contextdata structure in order to prevent null-
    reference errors in the renderer.
    zvertex-attrib)r6   ŚasArrayr5   ZsetValueZvoidDataPointer)	r>   r`   r   r   Ś
normalizedZstrider#   ŚarrayrI   r   r   r   ŚglVertexAttribPointerć  s    ’rn   c                 C   s:   |du r|}d}t j |”}|du r0t j |”}| ||S )zzglDrawBuffers( bufs ) -> bufs

    Wrapper will calculate n from dims of bufs if only
    one argument is provided...
    N)r   r7   rk   Z	arraySize)r>   Śnr   r   r   r   ŚglDrawBuffers	  s    rp   )N)N)N)NN)uŚ__doc__r   r   r   r   r   r   rD   ZOpenGL.raw.GLr   r   ZOpenGL.raw.GL.VERSION.GL_2_0r
   r   rp   ZsetInputArraySizera   Z	setOutputrc   rV   rL   Z_glget_size_mappingrU   r@   rE   rW   ZglGetVertexAttribdvZglGetVertexAttribfvZglGetVertexAttribivZglGetVertexAttribPointervr9   ZglUniform1fvZglUniform2fvZglUniform3fvZglUniform4fvZglUniform1ivZglUniform2ivZglUniform3ivZglUniform4ivZglUniformMatrix2fvZglUniformMatrix3fvZglUniformMatrix4fvZglVertexAttrib1dvZglVertexAttrib1fvZglVertexAttrib1svZglVertexAttrib2dvZglVertexAttrib2fvZglVertexAttrib2svZglVertexAttrib3dvZglVertexAttrib3fvZglVertexAttrib3svZglVertexAttrib4NbvZglVertexAttrib4NivZglVertexAttrib4NsvZglVertexAttrib4NubvZglVertexAttrib4NuivZglVertexAttrib4NusvZglVertexAttrib4bvZglVertexAttrib4dvZglVertexAttrib4fvZglVertexAttrib4ivZglVertexAttrib4svZglVertexAttrib4ubvZglVertexAttrib4uivZglVertexAttrib4usvr)   ZOpenGL._bytesr*   r+   r,   Z OpenGL.raw.GL.ARB.shader_objectsr-   rK   r.   ZGL_OBJECT_LINK_STATUSr/   ZGL_OBJECT_ACTIVE_UNIFORMSr0   Z#GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTHZOpenGL.lazywrapperr1   Z_lazyr2   r3   r4   r5   ZOpenGL.arrays.arraydatatyper6   r7   ŚConstantr8   ZcreateExtensionFunctionZPLATFORMZGLZGLhandleZGLsizeiZPOINTERŚc_char_pr<   ZStringLengthsŚconvZsetPyConverterZstringArrayZsetCResolverZstringArrayForCZsetCConverterZ
totalCountŚ	NameErrorŚerrrM   ZERROR_CHECKINGZglCompileShaderZerrcheckZglLinkProgramri   rj   rn   r   r   r   r   Ś<module>   sī  	
’
’żūł	
’żūł
’ż

’
’ż

’
’ż
’ż
’
’
’
’
’ż
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
’
üļ
žūł	öņī’






&



%