
    _eO	                     0    d Z ddlmZ d Z G d de      Zy)zSelection-buffer handling code

This code is resonsible for turning gluint *
arrays into structured representations for use
by Python-level code.
    )integer_typesc                      | dk  r| dz  dz   } | S )Nr   il         )values    5/usr/lib/python3/dist-packages/OpenGL/GL/selection.py
uintToLongr   	   s    qy#z1L    c                   L    e Zd ZdZ ed      ZdZd Z ee      Zd Z	d Z
d Zy)	GLSelectRecorda  Minimalist object for storing an OpenGL selection-buffer record
    
    Provides near and far as *float* values by dividing by 
    self.DISTANCE_DIVISOR (2**32-1)
    From the spec:
        Depth values (which are in the range [0,1]) are multiplied by 
        2^32 - 1, before being placed in the hit record.
    
    Names are unmodified, so normally are slices of the array passed in 
    to GLSelectRecord.fromArray( array )
    l    )nearfarnamesc                    g }d}t        |      }t        |      D ]g  }|dz   |k\  r |S ||   }||dz      }||dz      }	||dz   |dz   |z    D 
cg c]  }
t        |
       }}
|j                   | ||	|             |d|z   z  }i |S c c}
w )z,Produce list with all records from the arrayr            )lenranger   append)clsarraytotalresultindexarrayLengthitemcountr   r   vr   s               r   	fromArrayzGLSelectRecord.fromArray   s    %j5N 	DqyK'  %LEq>Da.C-257575=-IJjmJEJMMCsE35QuWE	  Ks   Bc                 j    | j                  |      | _        | j                  |      | _        || _        y)zInitialise/store the valuesN)convertDistancer   r   r   )selfr   r   r   s       r   __init__zGLSelectRecord.__init__.   s-    (($0	''.
r	   c                 2    t        |      | j                  z  S )z?Convert a distance value from array uint to 0.0-1.0 range float)r   DISTANCE_DIVISOR)r"   r   s     r   r!   zGLSelectRecord.convertDistance3   s    5"T%:%:::r	   c                     t        |t              r&| j                  | j                  | j                  f|   S || j
                  v r	 t        | |      S y# t        $ r!}t        d|d| j                  d      d}~ww xY w)z.Allow for treating the record as a three-tuplezDon't have an index/key z for z instantN)

isinstancer   r   r   r   	__slots__getattrAttributeErrorKeyError	__class__)r"   keyerrs      r   __getitem__zGLSelectRecord.__getitem__6   sz    sM*IIdhhtzz2377DNN"c++ # " !  s   A 	A=A88A=N)__name__
__module____qualname____doc__floatr%   r(   r   classmethodr#   r!   r/   r   r	   r   r   r      s9    
 Y'&I Y(I
;
r	   r   N)r3   OpenGL._bytesr   r   objectr   r   r	   r   <module>r8      s     (1f 1r	   