
    kj                     ^    d dl mZ d dlmZmZ d dlZd dlmZ d dlm	Z	  G d de          Z
dS )    )Path)AnyOptionalN)
BaseWindow)Keysc                   f    e Zd ZdZdZeZdef fdZe	de
j        fd            ZddZdd	Ze	deeef         fd
            Zej        deeef         ddfd            ZddZ	 	 	 	 	 	 ddedededededeeeeeef                  ddfdZddZdeddfdZdeddfdZdeddfdZddZ xZS )WindowzXHeadless window.

    Do not currently support any form window events or key input.
    headlesskwargsc                      t                      j        di | d | _        d| _        d| _        d| _        d| _        |                                  |                                  d S )NFT )	super__init___fbo_vsync
_resizable_cursor	_headlessinit_mgl_contextset_default_viewport)selfr   	__class__s     b/home/agentuser/manim-venv/lib/python3.11/site-packages/moderngl_window/context/headless/window.pyr   zWindow.__init__   sm    ""6"""48	!!#####    returnc                 <    | j         t          d          | j         S )z-moderngl.Framebuffer: The default framebufferNNo framebuffer created yet)r   RuntimeErrorr   s    r   fboz
Window.fbo   s#     9;<<<yr   Nc                     | j         &t          j        | j        | j                   | _        nt          j        | j                  | _        |                                  |                                  dS )z,Create an standalone context and framebufferN)requirebackend)r"   )_backendmodernglcreate_standalone_contextgl_version_code_ctx_create_fbouser   s    r   r   zWindow.init_mgl_context%   sv    =$ :,  DII
 !:,  DI 	




r   c                    | j         rf| j         j        D ]}|                                 | j         j        r| j         j                                         | j                                          | j                            | j                            | j        d| j                  | j        	                    | j        | j                            | _         d S )N   )samples)color_attachmentsdepth_attachment)
r   r.   releaser/   ctxframebuffertexturesize_samplesdepth_texture)r   
attachments     r   r)   zWindow._create_fbo4   s    9 	 "i9 % %
""$$$$y) 5	*22444IH(("h..ty!T].SS!X33DIt}3UU ) 
 
			r   c                     | j         | j        fS )ztuple[int, int]: current window size.

        This property also support assignment::

            # Resize the window to 1000 x 1000
            window.size = 1000, 1000
        )_width_heightr   s    r   r4   zWindow.sizeA   s     {DL((r   valuec                 t    || j         | j        fk    rd S |\  | _         | _        |                                  d S N)r9   r:   r)   r   r;   s     r   r4   zWindow.sizeL   sA    T[$,///F$)!T\r   c                 d    | j         t          d          | j                                          dS )zBind the window's framebufferNr   )r   r   r*   r   s    r   r*   z
Window.useS   s,    9;<<<	r                 ?redgreenbluealphadepthviewportc                 n    |                                   | j                            ||||||           dS )aD  
        Binds and clears the default framebuffer

        Args:
            red (float): color component
            green (float): color component
            blue (float): color component
            alpha (float): alpha component
            depth (float): depth value
            viewport (tuple): The viewport
        )rB   rC   rD   rE   rF   rG   N)r*   r(   clear)r   rB   rC   rD   rE   rF   rG   s          r   rI   zWindow.clearY   sF    ( 	


	5t5PX 	 	
 	
 	
 	
 	
r   c                 X    | xj         dz  c_         | j                                         dS )z~
        Placeholder. We currently don't do double buffering in headless mode.
        This may change in the future.
           N)_framesr(   finishr   s    r   swap_bufferszWindow.swap_buffersr   s.     		r   	icon_pathc                     dS )zDo nothing when icon is setNr   )r   rO   s     r   	_set_iconzWindow._set_icon{       r   c                     dS )z%Do nothing when fullscreen is toggledNr   r>   s     r   _set_fullscreenzWindow._set_fullscreen   rR   r   c                     d S r=   r   r>   s     r   
_set_vsynczWindow._set_vsync   s    r   c                 8    | j                                          dS )zDestroy the contextN)r(   r0   r   s    r   destroyzWindow.destroy   s    	r   )r   N)r@   r@   r@   r@   rA   N)__name__
__module____qualname____doc__namer   keysr   r   propertyr%   Framebufferr    r   r)   tupleintr4   setterr*   floatr   rI   rN   r   rQ   boolrT   rV   rX   __classcell__)r   s   @r   r	   r	   
   s9         DD$ $ $ $ $ $ $ X)    X   
 
 
 
 )eCHo ) ) ) X) 
[%S/ d    [    8<
 

 
 	

 
 
 5c3!345
 

 
 
 
2   4 D    T d                r   r	   )pathlibr   typingr   r   r%   moderngl_window.context.baser   %moderngl_window.context.headless.keysr   r	   r   r   r   <module>rk      s                           3 3 3 3 3 3 6 6 6 6 6 6~ ~ ~ ~ ~Z ~ ~ ~ ~ ~r   