
    ^j$m                       U d Z ddlmZ ddlZddlZddlmZmZmZm	Z	m
Z
mZmZ ddlZddlmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZ ddlm Z  ddl!m"Z" erdd	l#m$Z$ dd
l%m&Z&m'Z' ej(        d         Z)d/dZ*d0dZ+dZ,de-d<   dZ.de-d<   dZ/de-d<   dZ0de-d<   d1d!Z1d2d#Z2d2d$Z3ej4        ej5        ej6        ej7        d%Z8d&e-d'<   ee9e:e:e;f         Z< G d( d           Z= G d) d*          Z> G d+ d,e>          Z? G d- d.e>          Z@dS )3a)  Low-level graphics rendering and abstractions.

This module provides efficient abstractions over OpenGL objects, such as
Shaders and Buffers. It also provides classes for highly performant batched
rendering and grouping.

See the :ref:`guide_graphics` for details on how to use this graphics API.
    )annotationsN)TYPE_CHECKINGAnyCallableDictListSequenceTuple)GL_TEXTURE0GL_UNSIGNED_BYTEGL_UNSIGNED_INTGL_UNSIGNED_SHORTGLuintglActiveTextureglBindTextureglBindVertexArrayglDeleteVertexArraysglDrawArraysglDrawElementsglFlushglGenVertexArrays)shadervertexdomain)VertexArray)BufferObject)ShaderProgram)IndexedVertexList
VertexListdebug_graphics_batchsizeintmodedatar   returnNonec           	        t                      }t          d|           t          |           t                      }|                                 g }|                                D ]\  }\  }}|j        |         d         }	|j        |         d         }
t          j        |d                  }d|v }t          j
        ||	|
||d          }| t          |          |j        z  k    sJ d| d            t          | |j        z            } |j        t          |          z  | }|                    |           |                                 |                    |j                   |                    |           t+          |d|            |                                 ~t          d           t/          d|           d	S )
a  Draw a primitive immediately.

    :warning: This function is deprecated as of 2.0.4, and will be removed
              in the next release.

    Args:
        size:
            Number of vertices given
        mode:
            OpenGL drawing mode, e.g. ``GL_TRIANGLES``, avoiding quotes.
        **data: keyword arguments for passing vertex attribute data.
            The keyword should be the vertex attribute name, and the
            argument should be a tuple of (format, data). For example:
            `position=('f', array)`

       locationcountr   nF	Data for  is incorrect lengthN)r   r   r   get_default_shaderuseitems
attributesr   	_gl_typesr   	Attributelenr)   r   stridec_typeset_dataenableset_pointerptrappendr   stopr   )r    r"   r#   vao_idprogrambuffersnamefmtarrayr(   r)   gl_type	normalize	attributebuffers                  S/home/agentuser/manim-venv/lib/python3.11/site-packages/pyglet/graphics/__init__.pydrawrG   *   s   $ XXFa   f ""GKKMMMG"jjll  lsE%d+J7"4(1(Q03J	$T8UGYPUVV	s5zzY_44446[#6[6[6[444dY%5566-	 3u::-6fj)))vq$ LLNNNaF#####    indicesSequence[int]c           	        t                      }t          d|           t          |           t                      }|                                 g }|                                D ]\  }\  }}	|j        |         d         }
|j        |         d         }t          j        |d                  }d|v }t          j
        ||
|||d          }| t          |	          |j        z  k    sJ d| d            t          | |j        z            } |j        t          |	          z  |	 }|                    |           |                                 |                    |j                   |                    |           | d	k    rt*          }t,          j        }n-| d
k    rt0          }t,          j        }nt4          }t,          j        } |t          |          z  | }t          t-          j        |                    }|                    |           |                                 t=          |t          |          |d           t?                       |                                  ~~t          d           tC          d|           dS )aw  Draw a primitive with indexed vertices immediately.

    :warning: This function is deprecated as of 2.0.4, and will be removed
              in the next release.

    Args:
        size:
            Number of vertices given
        mode:
            OpenGL drawing mode, e.g. ``GL_TRIANGLES``
        indices:
            Sequence of integers giving indices into the vertex list.
        **data: keyword arguments for passing vertex attribute data.
            The keyword should be the vertex attribute name, and the
            argument should be a tuple of (format, data). For example:
            `position=('f', array)`

    r'   r(   r)   r   r*   Fr+   r,      i  N)"r   r   r   r-   r.   r/   r0   r   r1   r   r2   r3   r)   r   r4   r5   r6   r7   r8   r9   r:   r   ctypesc_ubyter   c_ushortr   c_uintsizeofbind_to_index_bufferr   r   r;   r   )r    r"   rI   r#   r<   r=   r>   r?   r@   rA   r(   r)   rB   rC   rD   rE   
index_typeindex_c_typeindex_arrayindex_buffers                       rF   draw_indexedrW   ^   s]   ( XXFa   f ""GKKMMMG"jjll  lsE%d+J7"4(1(Q03J	$T8UGYPUVV	s5zzY_44446[#6[6[6[444dY%5566-	 3u::-6fj)))vt||%
~	&
$
} /<#g,,.9Kk : :;;L+&&&%%'''4Wz1555III LLNNNaF#####rH   a  #version 330 core
    in vec3 position;
    in vec4 colors;
    in vec3 tex_coords;
    out vec4 vertex_colors;
    out vec3 texture_coords;

    uniform WindowBlock
    {
        mat4 projection;
        mat4 view;
    } window;

    void main()
    {
        gl_Position = window.projection * window.view * vec4(position, 1.0);

        vertex_colors = colors;
        texture_coords = tex_coords;
    }
str_vertex_sourcez#version 330 core
    in vec4 vertex_colors;
    in vec3 texture_coords;
    out vec4 final_colors;

    uniform sampler2D our_texture;

    void main()
    {
        final_colors = texture(our_texture, texture_coords.xy) + vertex_colors;
    }
_fragment_sourceaF  #version 330 core
    in vec3 position;
    in vec3 tex_coords;
    out vec3 texture_coords;

    uniform WindowBlock
    {
        mat4 projection;
        mat4 view;
    } window;

    void main()
    {
        gl_Position = window.projection * window.view * vec4(position, 1.0);

        texture_coords = tex_coords;
    }
_blit_vertex_sourcez#version 330 core
    in vec3 texture_coords;
    out vec4 final_colors;

    uniform sampler2D our_texture;

    void main()
    {
        final_colors = texture(our_texture, texture_coords.xy);
    }
_blit_fragment_sourceBatchc                     	 t           j        j        j        S # t          $ r; t                      t           j        j        _        t           j        j        j        cY S w xY w)z=Batch used globally for objects that have no Batch specified.)pygletglcurrent_contextpyglet_graphics_default_batchAttributeErrorr]    rH   rF   get_default_batchre      sZ    Gy(FF G G GBG''	!?y(FFFFGs    AAAr   c                 X   	 t           j        j        j        j        S # t
          $ r t          j        t          d          } t          j        t          d          }t          j
        | |          }|t           j        j        j        _        t           j        j        j        j        cY S w xY w)z+A default basic shader for default batches.vertexfragment)r_   r`   ra   object_spacepyglet_graphics_default_shaderrc   r   ShaderrY   rZ   r   _vertex_shader_fragment_shader_shader_programs      rF   r-   r-      s    Uy(5TT U U U~x@@!=)9:FF .~?OPPP_	!.My(5TTTTU    B	B)(B)c                 X   	 t           j        j        j        j        S # t
          $ r t          j        t          d          } t          j        t          d          }t          j
        | |          }|t           j        j        j        _        t           j        j        j        j        cY S w xY w)z:A default basic shader for blitting, provides no blending.rg   rh   )r_   r`   ra   ri   #pyglet_graphics_default_blit_shaderrc   r   rk   r[   r\   r   rl   s      rF   get_default_blit_shaderrs      s    Zy(5YY Z Z Z':HEE!=)>
KK .~?OPPUd	!.Ry(5YYYYZrp   ))FF)TF)FT)TTz8dict[tuple[bool, bool], type[vertexdomain.VertexDomain]]_domain_class_mapc                      e Zd ZU dZded<   ded<   ded<   ded	<   d.dZd.dZd/dZd0dZd1dZ	d2d%Z
d3d&Zd.d'Zd.d(Zd.d)Zd4d,Zd-S )5r]   aw  Manage a collection of drawables for batched rendering.

    Many drawable pyglet objects accept an optional `Batch` argument in their
    constructors. By giving a `Batch` to multiple objects, you can tell pyglet
    that you expect to draw all of these objects at once, so it can optimise its
    use of OpenGL. Hence, drawing a `Batch` is often much faster than drawing
    each contained drawable separately.

    The following example creates a batch, adds two sprites to the batch, and
    then draws the entire batch::

        batch = pyglet.graphics.Batch()
        car = pyglet.sprite.Sprite(car_image, batch=batch)
        boat = pyglet.sprite.Sprite(boat_image, batch=batch)

        def on_draw():
            batch.draw()

    While any drawables can be added to a `Batch`, only those with the same
    draw mode, shader program, and group can be optimised together.

    Internally, a `Batch` manages a set of VertexDomains along with
    information about how the domains are to be drawn. To implement batching on
    a custom drawable, get your vertex domains from the given batch instead of
    setting them up yourself.
    zlist[Callable]
_draw_listzlist[Group]
top_groupszdict[Group, list[Group]]group_childrenz7dict[Group, dict[DomainKey, vertexdomain.VertexDomain]]	group_mapr$   r%   c                    i | _         i | _        g | _        g | _        d| _        t
          j        j        | _        d| _	        dS )zCreate a graphics batch.Fr   N)
ry   rx   rw   rv   _draw_list_dirtyr_   r`   ra   _context_instance_countselfs    rF   __init__zBatch.__init__5  sG      !  %	1 rH   c                    d| _         dS )zForce the batch to update the draw list.

        This method can be used to force the batch to re-compute the draw list
        when the ordering of groups has changed.

        .. versionadded:: 1.2
        TN)r{   r~   s    rF   
invalidatezBatch.invalidateH  s     !%rH   vertex_listVertexList | IndexedVertexListr"   r!   groupGroupr=   r   boolc                2   |j                                         }|D ]J}||j        v r?|j        |         d         ||         d         k    r|j        |         d         ||         d<   K|                     |j        |j        |||          }||j        k    rdS dS )a  Migrate a vertex list to another domain that has the specified shader attributes.

        The results are undefined if `mode` is not correct or if `vertex_list`
        does not belong to this batch (they are not checked and will not
        necessarily throw an exception immediately).

        Args:
            vertex_list:
                A vertex list currently belonging to this batch.
            mode:
                The current GL drawing mode of the vertex list.
            group:
                The new group to migrate to.
            program:
                The new shader program to migrate to.

        Returns:
            False if the domain's no longer match. The caller should handle this scenario.
        formatFT)r0   copyinitial_attribs
get_domainindexed	instanceddomain)r   r   r"   r   r=   r0   a_namer   s           rF   update_shaderzBatch.update_shaderR  s    , ',,..
 ! 	] 	]F+555/7AZPVEWX`Eaaa/:/J6/RS[/\
6"8,!4k6KTSXZdee ['''5trH   batchc                    |j         j        }|                    |j        |j        |||          }|                    |           dS )aD  Migrate a vertex list to another batch and/or group.

        `vertex_list` and `mode` together identify the vertex list to migrate.
        `group` and `batch` are new owners of the vertex list after migration.

        The results are undefined if `mode` is not correct or if `vertex_list`
        does not belong to this batch (they are not checked and will not
        necessarily throw an exception immediately).

        ``batch`` can remain unchanged if only a group change is desired.

        Args:
            vertex_list:
                A vertex list currently belonging to this batch.
            mode:
                The current GL drawing mode of the vertex list.
            group:
                The new group to migrate to.
            batch:
                The batch to migrate to (or the current batch).

        N)r   attribute_metar   r   r   migrate)r   r   r"   r   r   r0   r   s          rF   r   zBatch.migratez  sL    . !'6
!!+"5{7LdTY[effF#####rH   r   <vertexdomain.VertexDomain | vertexdomain.IndexedVertexDomaininstance_attributesSequence[str]Nvertexdomain.InstancedVertexDomain | vertexdomain.InstancedIndexedVertexDomainc           	        | j                                         D ]\  }}|                                D ]{\  }}||k    rp|j                                        }|                                D ]\  }}	||v rd|	d<   |\  }
}}}|dk    s
J d            |                     |
d|||          c c S |d}t          |          )zITakes a domain from inside the Batch and creates a new instanced version.Tinstancer   z#Cannot convert an instanced domain.z0Domain was not found and could not be converted.)ry   r/   r   r   r   	Exception)r   r   r   r   
domain_mapkeymapped_domainnew_attributesr?   attribute_dictdindexed
dinstanceddmode_msgs                  rF   _convert_to_instancedzBatch._convert_to_instanced  s    "&!5!5!7!7 	Y 	YE:&0&6&6&8&8 
Y 
Y"]]**%2%A%F%F%H%HN0>0D0D0F0F > >,n#6669=N:6582Hj%%???,Q?????8T5%XXXXXXX +
Y AnnrH   r   r   r0   dict[str, Any]vertexdomain.VertexDomain | vertexdomain.IndexedVertexDomain | vertexdomain.InstancedVertexDomain | vertexdomain.InstancedIndexedVertexDomainc                R   || j         vr|                     |           | j         |         }|r)| xj        dz  c_        || j        |t          |          f}n|d|t          |          f}	 ||         }n3# t          $ r& t          ||f         |          }|||<   d| _        Y nw xY w|S )zGet, or create, the vertex domain corresponding to the given arguments.

        mode is the render mode such as GL_LINES or GL_TRIANGLES
        r'   r   T)ry   
_add_groupr}   rX   KeyErrorrt   r{   )	r   r   r   r"   r   r0   r   r   r   s	            rF   r   zBatch.get_domain  s     &&OOE"""^E*
  	6  A%  D0$JHCC AtS__5C	)_FF 	) 	) 	)&';<ZHHF$JsO$(D!!!		) s   +A4 4-B$#B$c                t   i | j         |<   |j        | j                            |           nj|j        | j         vr|                     |j                   |j        | j        vrg | j        |j        <   | j        |j                                     |           |j                            |            d| _        d S )NT)	ry   parentrw   r:   r   rx   _assigned_batchesaddr{   )r   r   s     rF   r   zBatch._add_group  s     "u<O""5))))|4>11---|4#66646#EL1-44U;;;##D))) $rH   c                "    d fdg  _          j                                         t           j                  D ],}|j        r# j                              |                     -d _        t          r                                  dS dS )	zHVisit group tree in preorder and create a list of bound methods to call.r   r   r$   listc                   g }
j         |          }t          |                                          D ]9\  \  }}}}}|j        r|||||f= |                     d ||                     :
j                            |           }|rK|                                 t          |          D ]'}	|	j        r|	                     |	                     (|s|r| j
        g|| j        S 
j         | = | j                            
           | j        r%
j        | j                                     |            	 
j        | = n# t          $ r Y nw xY w	 
j                            |            n# t"          $ r Y nw xY wg S )Nc                      fdS )Nc                 .                                    S N)rG   dms   rF   <lambda>zJBatch._update_draw_list.<locals>.visit.<locals>.<lambda>.<locals>.<lambda>  s    qvvayy rH   rd   r   s   ``rF   r   z8Batch._update_draw_list.<locals>.visit.<locals>.<lambda>  s    /@/@/@/@/@ rH   )ry   r   r/   is_emptyr:   rx   getsortvisibleextend	set_stateunset_stater   remover   r   rw   
ValueError)r   	draw_listr   r   r   r"   formatsr   childrenchildr   visits             rF   r   z&Batch._update_draw_list.<locals>.visit  s   I .J @DJDTDTDVDV?W?W Q Q;3)T7V? "GYg#FG  "@"@"@&$!O!OPPPP *..u55H 7!(^^ 7 7E} 7!((u666 H: HG)GU5FGG u%#**4000| @#EL188???'..   &&u----    Is$   7E   
EEE, ,
E98E9FN)r   r   r$   r   )	rv   rw   r   r   r   r   r{   _debug_graphics_batch_dump_draw_list)r   	top_groupr   s   ` @rF   _update_draw_listzBatch._update_draw_list  s    '	 '	 '	 '	 '	 '	 '	R do.. 	9 	9I  9&&uuY'7'7888 %  	#  """""	# 	#rH   c                j     dd fdt          d	 d
            j        D ]} |           d S )N r   r   indentrX   r$   r%   c           	        t          |d|            j        |          }|                                D ]}t          |d|           t          |j                                         D ]\  }}t          |dd||fz             |j                                        D ]b\  }}t          |dd           	 |                    ||          }t          ||j	        d d                     L#  t          |d           Y `xY w̉j
                            | d	          D ]}	 
|	|dz              t          |d
|            d S )NzBegin groupz  z    zRegion %d size %d:z       )endz(unmappable)rd   z	End group)printry   valueszip	allocatorget_allocated_regionsattrib_name_buffersr/   
get_regionrA   rx   r   )r   r   r   r   startr    r   rE   regionr   dumpr   s             rF   r   z#Batch._dump_draw_list.<locals>.dump  s}   &-///.J$++-- 
7 
7fdF+++#&(8(N(N(P(P#Q 7 7KE4&&*>%*NOOO'-'A'G'G'I'I 7 7VfhC88887%+%6%6ud%C%CF!#v|AAA77777!#~6666677 ,00;; + +UFTM****&+u-----s   33C''C;	zDraw list for :)r   )r   r   r   rX   r$   r%   )r   rw   )r   r   r   s   ` @rF   r   zBatch._dump_draw_list  sr    	. 	. 	. 	. 	. 	. 	. 	.$ 	(t((()))_ 	 	EDKKKK	 	rH   c                d    | j         r|                                  | j        D ]} |             dS )zDraw the batch.N)r{   r   rv   )r   funcs     rF   rG   z
Batch.draw(  sG      	%""$$$O 	 	DDFFFF	 	rH   vertex_lists(Sequence[VertexList | IndexedVertexList]c                     d fd j                                           j         D ]}|j        r |           dS )a  Draw only some vertex lists in the batch.

        The use of this method is highly discouraged, as it is quite
        inefficient.  Usually an application can be redesigned so that batches
        can always be drawn in their entirety, using `draw`.

        The given vertex lists must belong to this batch; behaviour is
        undefined if this condition is not met.

        Args:
            vertex_lists:
                Vertex lists to draw.

        r   r   r$   r%   c                   |                                   j        |          }|                                D ].\  \  }}}}}}	D ] }|j        |u r|                    |           !/j                            |           }|r+|                                 |D ]}|j        r 
|           | 	                                 d S r   )
r   ry   r/   r   rG   rx   r   r   r   r   )r   r   r   r"   r   alistr   r   r   r   r   s           rF   r   z Batch.draw_subset.<locals>.visitA  s    OO .J.8.>.>.@.@ ) )*"AtQF) ) )E|v--

4((()
 *..u55H %% % %E} %erH   Nr   r   r$   r%   )rw   r   r   )r   r   r   r   s   `` @rF   draw_subsetzBatch.draw_subset0  sz    "	  	  	  	  	  	  	  	 ( 	 	! 	!I  !i   	! 	!rH   Nr$   r%   )
r   r   r"   r!   r   r   r=   r   r$   r   )
r   r   r"   r!   r   r   r   r]   r$   r%   )r   r   r   r   r$   r   )r   r   r   r   r"   r!   r   r   r0   r   r$   r   r   )r   r   r$   r%   )__name__
__module____qualname____doc____annotations__r   r   r   r   r   r   r   r   r   rG   r   rd   rH   rF   r]   r]     s1         4 ,,,,FFFF! ! ! !&% % % %& & & &P$ $ $ $6   ,   @% % % %6# 6# 6# 6#p   .   (! (! (! (! (! (!rH   c                      e Zd ZdZddd
Zedd            Zedd            Zej        d d            Zed!d            Z	d"dZ
d"dZddZd#dZd$dZd$dZd$dZd$dZdS )%r   al  Group of common OpenGL state.

    ``Group`` provides extra control over how drawables are handled within a
    ``Batch``. When a batch draws a drawable, it ensures its group's state is set;
    this can include binding textures, shaders, or setting any other parameters.
    It also sorts the groups before drawing.

    In the following example, the background sprite is guaranteed to be drawn
    before the car and the boat::

        batch = pyglet.graphics.Batch()
        background = pyglet.graphics.Group(order=0)
        foreground = pyglet.graphics.Group(order=1)

        background = pyglet.sprite.Sprite(background_image, batch=batch, group=background)
        car = pyglet.sprite.Sprite(car_image, batch=batch, group=foreground)
        boat = pyglet.sprite.Sprite(boat_image, batch=batch, group=foreground)

        def on_draw():
            batch.draw()
    r   Norderr!   r   Group | Noner$   r%   c                `    || _         || _        d| _        t          j                    | _        dS )a-  Initialize a rendering group.

        Args:
            order:
                Set the order to render above or below other Groups.
                Lower orders are drawn first.
            parent:
                Group to contain this Group; its state will be set before this Group's state.
        TN)_orderr   _visibleweakrefWeakSetr   )r   r   r   s      rF   r   zGroup.__init__r  s/     !(!2!2rH   c                    | j         S )zbRendering order of this group compared to others.

        Lower numbers are drawn first.
        )r   r~   s    rF   r   zGroup.order  s     {rH   r   c                    | j         S )zVisibility of the group in the rendering pipeline.

        Determines whether this Group is visible in any of the Batches
        it is assigned to. If ``False``, objects in this Group will not
        be rendered.
        )r   r~   s    rF   r   zGroup.visible  s     }rH   valuec                P    || _         | j        D ]}|                                 d S r   )r   r   r   )r   r   r   s      rF   r   zGroup.visible  s:    + 	 	E	 	rH   tuple[Batch, ...]c                *    t          | j                  S )zLWhich graphics Batches this Group is a part of.

        Read Only.
        )tupler   r~   s    rF   batcheszGroup.batches  s     T+,,,rH   otherc                "    | j         |j        k     S r   )r   r   r   r   s     rF   __lt__zGroup.__lt__  s    {U[((rH   c                ^    | j         |j         u o| j        |j        k    o| j        |j        k    S )aq  Comparison function used to determine if another Group is providing the same state.

        When the same state is determined, those groups will be consolidated into one draw call.

        If subclassing, then care must be taken to ensure this function can compare to another of the same group.

        :see: ``__hash__`` function, both must be implemented.
        )	__class__r   r   r   r   s     rF   __eq__zGroup.__eq__  s7     %/1 ,u{*,u|+	-rH   c                8    t          | j        | j        f          S )a  This is an immutable return to establish the permanent identity of the object.

        This is used by Python with ``__eq__`` to determine if something is unique.

        For simplicity, the hash should be a tuple containing your unique identifiers of your Group.

        By default, this is (``order``, ``parent``).

        :see: ``__eq__`` function, both must be implemented.
        )hashr   r   r~   s    rF   __hash__zGroup.__hash__  s     T[$+.///rH   rX   c                0    | j         j         d| j         dS )Nz(order=))r  r   r   r~   s    rF   __repr__zGroup.__repr__  s     .)@@$+@@@@rH   c                    dS )zYApply the OpenGL state change.

        The default implementation does nothing.
        Nrd   r~   s    rF   r   zGroup.set_state        rH   c                    dS )zZRepeal the OpenGL state change.

        The default implementation does nothing.
        Nrd   r~   s    rF   r   zGroup.unset_state  r  rH   c                n    | j         r| j                                          |                                  dS )zSet this group and its ancestry.

        Call this method if you are using a group in isolation: the
        parent groups will be called in top-down order, with this class's
        ``set`` being called last.
        N)r   set_state_recursiver   r~   s    rF   r  zGroup.set_state_recursive  s8     ; 	.K++---rH   c                r    |                                   | j        r| j                                         dS dS )z\Unset this group and its ancestry.

        The inverse of ``set_state_recursive``.
        N)r   r   unset_state_recursiver~   s    rF   r  zGroup.unset_state_recursive  sD    
 	; 	0K--/////	0 	0rH   r   N)r   r!   r   r   r$   r%   r$   r!   )r$   r   )r   r   r$   r%   )r$   r   )r   r   r$   r   r$   rX   r   )r   r   r   r   r   propertyr   r   setterr   r   r  r  r	  r   r   r  r  rd   rH   rF   r   r   [  s]        ,3 3 3 3 3    X    X ^   ^ - - - X-) ) ) )- - - -0 0 0 0A A A A      	 	 	 	0 0 0 0 0 0rH   r   c                  F     e Zd ZdZdd fdZddZddZddZddZ xZ	S )ShaderGroupz/A group that enables and binds a ShaderProgram.r   Nr=   r   r   r!   r   r   r$   r%   c                Z    t                                          ||           || _        d S r   )superr   r=   )r   r=   r   r   r  s       rF   r   zShaderGroup.__init__  s(    '''rH   c                8    | j                                          d S r   )r=   r.   r~   s    rF   r   zShaderGroup.set_state  s    rH   c                8    | j                                          d S r   )r=   r;   r~   s    rF   r   zShaderGroup.unset_state  s    rH   r   r   c                ~    | j         |j         u o/| j        |j        k    o| j        |j        k    o| j        |j        k    S r   )r  r   r   r=   r   r   s     rF   r  zShaderGroup.__eq__  sH    %/1 ,u{*,-, u|+	-rH   c                D    t          | j        | j        | j        f          S r   )r  r   r   r=   r~   s    rF   r  zShaderGroup.__hash__  s    T[$+t|<===rH   r  )r=   r   r   r!   r   r   r$   r%   r   )r   r  r$   r   r  )
r   r   r   r   r   r   r   r  r  __classcell__r  s   @rF   r  r    s        99            - - - -> > > > > > > >rH   r  c                  F     e Zd ZdZdd fdZddZddZddZddZ xZ	S )TextureGroupz{A group that enables and binds a texture.

    TextureGroups are equal if their textures' targets and names are equal.
    r   Ntexturepyglet.image.Texturer   r!   r   r   r$   r%   c                Z    t                                          ||           || _        dS )zCreate a texture group.

        Args:
            texture:
                Texture to bind.
            order:
                Change the order to render above or below other Groups.
            parent:
                Parent group.
        N)r  r   r"  )r   r"  r   r   r  s       rF   r   zTextureGroup.__init__  s*     	'''rH   c                v    t          t                     t          | j        j        | j        j                   d S r   )r   r   r   r"  targetidr~   s    rF   r   zTextureGroup.set_state  s/    $$$dl)4<?;;;;;rH   c                d    t          | j        j        | j        j        | j        | j        f          S r   )r  r"  r&  r'  r   r   r~   s    rF   r  zTextureGroup.__hash__  s&    T\($,/4:t{STTTrH   r   r   c                    | j         |j         u oS| j        j        |j        j        k    o9| j        j        |j        j        k    o| j        |j        k    o| j        |j        k    S r   )r  r"  r&  r'  r   r   r   s     rF   r  zTextureGroup.__eq__  sf    %/1 ,#u}';;,5=#33, 
ek), u|+		-rH   rX   c                :    | j         j         d| j        j         dS )Nz(id=r  )r  r   r"  r'  r~   s    rF   r	  zTextureGroup.__repr__  s"    .)AAt|AAAArH   r  )r"  r#  r   r!   r   r   r$   r%   r   r  )r   r!  r$   r   r  )
r   r   r   r   r   r   r  r  r	  r  r  s   @rF   r!  r!    s         
      < < < <U U U U- - - -B B B B B B B BrH   r!  )r    r!   r"   r!   r#   r   r$   r%   )
r    r!   r"   r!   rI   rJ   r#   r   r$   r%   )r$   r]   )r$   r   )Ar   
__future__r   rM   r   typingr   r   r   r   r   r	   r
   r_   pyglet.gl.glr   r   r   r   r   r   r   r   r   r   r   r   r   pyglet.graphicsr   r   pyglet.graphics.vertexarrayr   pyglet.graphics.vertexbufferr   pyglet.graphics.shaderr   pyglet.graphics.vertexdomainr   r   optionsr   rG   rW   rY   r   rZ   r[   r\   re   r-   rs   VertexDomainIndexedVertexDomainInstancedVertexDomainInstancedIndexedVertexDomainrt   r   r!   rX   	DomainKeyr]   r   r  r!  rd   rH   rF   <module>r9     s     # " " " " "   L L L L L L L L L L L L L L L L L L                               1 0 0 0 0 0 0 0 3 3 3 3 3 3 5 5 5 5 5 5 K444444JJJJJJJJ'=> 1$ 1$ 1$ 1$hF$ F$ F$ F$V    ,          &
  
 
 
 
G G G G	U 	U 	U 	U	Z 	Z 	Z 	Z !-35;O O      $S#%&	C! C! C! C! C! C! C! C!L
E0 E0 E0 E0 E0 E0 E0 E0T> > > > >% > > >.#B #B #B #B #B5 #B #B #B #B #BrH   