a
    ij                  '   @   s  d Z dZddlZzddlZW n0 eyL Z zede W Y dZ[n
dZ[0 0 ddlmZ ddlm	Z	 ddl
mZ ddlmZmZ G d	d
 d
ejZzedgd dZW n, ey Z zdZdZW Y dZ[n
dZ[0 0 dd Zedejedejedejeeejeeejedejedejedejedejddi
Zejedejedejedejedejeeejedejedejeee	jeddddeddeddeddeddeddeddeddeddediZ dS )a  Buffer based Numpy plugin (not used)

This API is no more useful than the direct Numpy version, as Numpy already 
gives us the details we need *when using the accelerator module* at a low 
level, with very fast access.  When using the non-accelerated version the 
ctypes version *might* show some performance benefits, but it's not going 
to be fast no matter what we do without C-level code.
Znumpybuffers    NzNo numpy module present: %s)buffers)_types)GL_1_1)constanterrorc                       s<   e Zd Zedd Zed fdd	Zed	ddZ  ZS )
NumpyHandlerc                 C   s   t |t| S )z)Return Numpy array of zeros in given size)numpyzerosGL_TYPE_TO_ARRAY_MAPPING)clsdimstypeCode r   X/home/ghrups/robot-bench/.venv/lib/python3.9/site-packages/OpenGL/arrays/numpybuffers.pyr	      s    zNumpyHandler.zerosNc                    s   t t| | |||S )z7Convert given value to an array value of given typeCode)superr   asArray
contiguous)r   valuer   	__class__r   r   r      s    zNumpyHandler.asArrayc              
   C   s   t | }z|jj}W nV tyj } z>|r@t||W  Y d}~S t|W  Y d}~S W Y d}~nd}~0 0 |r|du s||jjkr|S |r| jrddl	m
} |d|jj|n:| jrddl	m
} |d||du r|jj}t||S dS )aj  Get contiguous array from source

        source -- numpy Python array (or compatible object)
            for use as the data source.  If this is not a contiguous
            array of the given typeCode, a copy will be made,
            otherwise will just be returned unchanged.
        typeCode -- optional 1-character typeCode specifier for
            the numpy.array function.

        All gl*Pointer calls should use contiguous arrays, as non-
        contiguous arrays will be re-copied on every rendering pass.
        Although this doesn't raise an error, it does tend to slow
        down rendering.
        Nr   )r   z2Array of type %r passed, required array of type %rzNon-contiguous array passed)r
   flagsr   AttributeErrorr   ZascontiguousarraydtypecharZERROR_ON_COPYOpenGLr   Z	CopyError)r   sourcer   r   errr   r   r   r   r      s0    ,

zNumpyHandler.contiguous)N)N)__name__
__module____qualname__classmethodr	   r   r   __classcell__r   r   r   r   r      s   
r      shHc                 C   s   t jd| djS )N)r"   )r   )r   r	   r   )r   r   r   r   lookupDtypeT   s    r&   dfiBcbIP)!__doc__ZREGISTRY_NAMEoperatorr   ImportErrorr   ZOpenGL.arraysr   ZOpenGL.raw.GLr   ZOpenGL.raw.GL.VERSIONr   r   r   r   ZBufferHandlerr   arrayZ
SHORT_TYPE	TypeErrorZUSHORT_TYPEr&   Z	GL_DOUBLEZGL_FLOATZGL_INTZGL_SHORTZGL_UNSIGNED_SHORTZGL_UNSIGNED_BYTEZGL_BYTEZGL_UNSIGNED_INTZARRAY_TO_GL_TYPE_MAPPINGZ	GL_VOID_Pr
   r   r   r   r   <module>   sb   ":

















