
    _e                     Z   d Z dZddlZ	 ddlZ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
ej                        Z	  ej"                  dgd       dZd Z ed      ej,                   ed      ej.                   ed      ej0                   ee      ej2                   ee      ej4                   ed      ej6                   ed      ej6                   ed      ej8                   ed      ej:                  ddi
Zi ej,                   ed      ej.                   ed      ej0                   ed      ej8                   ed      ej2                   ee      ej:                   ed      ej6                   ed      ej4                   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       ed       ed      dZ y# e$ rZ edez        dZ[ww xY w# e$ rZdZdZY dZ[dZ[ww xY w)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.
numpybuffers    NzNo numpy module present: %s)buffers)_types)GL_1_1)constanterrorc                   L     e Zd Zed        Zed fd	       Zedd       Z xZS )NumpyHandlerc                 <    t        j                  |t        |         S )z)Return Numpy array of zeros in given size)numpyzerosGL_TYPE_TO_ARRAY_MAPPING)clsdimstypeCodes      </usr/lib/python3/dist-packages/OpenGL/arrays/numpybuffers.pyr   zNumpyHandler.zeros   s     {{D":8"DEE    c                 L    t         t        |   | j                  ||      |      S )z7Convert given value to an array value of given typeCode)superr
   asArray
contiguous)r   valuer   	__class__s      r   r   zNumpyHandler.asArray   s%     \#.uX0NPXZZr   c                 .   t         |   }	 |j                  j                  }|r|||j                  j                  k(  r|S |r:| j
                  r.ddlm}  |j                  d|j                  j                  |      | j
                  rddlm}  |j                  d|      ||j                  j                  }t        j                  ||      S # t        $ r<}|rt        j                  ||      cY d}~S t        j                  |      cY d}~S d}~ww xY w)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   dtypecharERROR_ON_COPYOpenGLr   	CopyErrorr   ascontiguousarrayAttributeError)r   sourcer   r   r   errs         r   r   zNumpyHandler.contiguous   s      ,X7	C00J x/8V\\=N=N3N!2!2(%eooLLL%%x  $$,)%//9  #%||00H..BB9  	9..BB..88		9s)   C 	DD/D5D	DD)N)__name__
__module____qualname__classmethodr   r   r   __classcell__)r   s   @r   r
   r
      sC    F F [ [ .C .Cr   r
      shHc                 D    t        j                  d|       j                  S )N)r*   )r   )r   r   r   )r   s    r   lookupDtyper/   T   s    ;;D*000r   dfiBcbIP)r3   r+   )!__doc__REGISTRY_NAMEoperatorr   ImportErrorr$   OpenGL.arraysr   OpenGL.raw.GLr   OpenGL.raw.GL.VERSIONr   r   r   r   BufferHandlerr
   array
SHORT_TYPE	TypeErrorUSHORT_TYPEr/   	GL_DOUBLEGL_FLOATGL_INTGL_SHORTGL_UNSIGNED_SHORTGL_UNSIGNED_BYTEGL_BYTEGL_UNSIGNED_INTARRAY_TO_GL_TYPE_MAPPING	GL_VOID_Pr    r   r   <module>rO      s    @ "   ( "9CG)) 9CtEKK!cJ
1 f&&foofmm
V__f66f--f--fnnf,,$ 
k#&
OOK$ MM;s# NNK$	
 OO[, K, [- k+6 k#& 	$ S	 S	 S	 S	 S	  S	!" S	#$ 
S		S	' o  @
8#>
??@F  JKs.   G> H >HHHH*H%%H*