
    3j6                        S r SSKJrJrJr  \R
                  rSSKJrJrJ	r	J
r
  SSKJr  SSKJrJrJr  SSKrSSKrSSKrSSKr\	R                  r\R*                  rSSKJrJr  \
R2                  " S5      r\R6                  S	:X  Ga
  \R9                  S
5        \" S\R:                  5      r\	R>                  " S\	R                  R
                  S\R@                  " \R:                  5      \R@                  " \RB                  5      \/SSS9r"\	R>                  " S\	R                  R
                  \R:                  \RB                  \/SSS9r#\	R>                  " S\	R                  R
                  \R:                  \" S\R:                  5      \/SSS9r$OSr"\"(       a   SSKr\" \RJ                  5      r&S r'S r(S r)OM\	RT                  " S\S\R@                  " \R:                  5      \R@                  " \RB                  5      4SS\+SS9r'\," \SS5      r- " S S\.5      r/ " S S \/5      r0 " S! S"\.5      r1\1RR                  r)\1Rd                  r2\/" S#\R:                  \R:                  4S$5      r3\/" S%\R:                  \R:                  4S&5      r4\/" S'S(S(5      r5\/" S)\R:                  4S*5      r6\/" S+S(S(5      r7\/" S,\Rp                  \R:                  \R:                  \R:                  4S-5      r9\/" S.\Rt                  \R:                  \R:                  4S/5      r;\/" S0\Rt                  \R:                  \R:                  4S/5      r<\/" S1\R:                  \R:                  \R:                  4S25      r=\/" S3\R:                  4S45      r>\/" S5\R:                  \R:                  4S65      r?\/" S7\R:                  \R:                  \R:                  \R:                  4S85      r@\/" S9S(S(5      rA\/" S:\R:                  \R:                  4S65      rB\/" S;\R:                  \R:                  4S<5      rC\/" S=\R:                  \R:                  4S$5      rD\/" S>\R:                  \R:                  \R:                  4S?5      rE\/" S@\R:                  \R:                  \R:                  4S?5      rF\/" SA\R:                  \R:                  \R:                  4S/5      rG\/" SB\R:                  \R:                  \R:                  4S/5      rH\/" SC\R:                  \R:                  \R:                  \R:                  4S85      rI\/" SC\R:                  \R:                  \R:                  \R:                  4S85      rI\/" SD\R:                  \R:                  4S65      rJ\/" SE\R:                  4S*5      rK\/" SF\R:                  4S*5      rL\0" SG\R:                  4SH5      rMSIqNSJ rO\R                  \OlP        SK rQ\R                  \QlP        g)La  GLUT functions requiring special handling to provide Pythonic wrappers

Note:
    GLUT callbacks are controlled by a flag in the platform module.  The
    GLUT_GUARD_CALLBACKS flag controls whether to wrap passed functions
    with error-checking and context-validity checking code so that the
    callbacks will only trigger if there is a valid context.  This is done
    so that systems such as Win32 will not continue running GLUT callbacks
    after the system has exited.

    Note:
        This is not a problem with FreeGLUT on Linux, so Linux does not
        add the extra overhead of the wrapper function.
    Note:
        This hack does *not* prevent hanging if there is no GLUT callback
        being triggered.  I.e. if you create a GLUT program that doesn't
        explicitly call exit and doesn't call display or the like in a timer
        then your app will hang on exit on Win32.

XXX the platform-specific stuff should be getting done in the 
platform module *not* in the module here!
    )CurrentContextIsValidGLUT_GUARD_CALLBACKSPLATFORM)contextdataerrorplatformlogs)GLUT)bytesunicodeas_8_bitN)longinteger_typeszOpenGL.GLUT.specialntz0Using NT-specific GLUT calls with exit callbacks__glutInitWithExitz@glutInit( POINTER(c_int)(pargc), POINTER(STRING)(argv) ) -> Nonepargcargv)dll
resultTypeargTypesdocargNames__glutCreateWindowWithExitz*glutCreateWindow( STRING(title) ) -> c_inttitle__glutCreateMenuWithExitz?glutCreateMenu( FUNCTION_TYPE(None, c_int)(callback) ) -> c_intcallbackc                 "    [        X[        5      $ )z9Overrides base glut init with exit-function-aware version)r   	_exitfuncr   s     M/home/wildlama/miniconda3/lib/python3.13/site-packages/OpenGL/GLUT/special.py_base_glutInitr#   @   s    !%y99    c                 "    [        U [        5      $ )zzCreate window with given title

This is the Win32-specific version that handles
registration of an exit-function handler 
)r   r!   r   s    r"   glutCreateWindowr&   C   s     *%;;r$   c                 "    [        U [        5      $ )z~Create menu with given callback 

This is the Win32-specific version that handles 
registration of an exit-function callback.
)r   r!   r   s    r"   glutCreateMenur(   J   s     ()<<r$   glutInitzInitialize the GLUT library)argcpr   )r   r   r   r   moduleerror_checkerglutDestroyWindowc                   (    \ rS rSrSrS rSrS rSrg)GLUTCallback`   z7Class implementing GLUT Callback registration functionsc                 ^  ^ TU l         S nST< SSR                  [        X#5       VVs/ s H  u  pVU" XV5      PM     snn5      < S3U l         [	        [
        ST-  5      U l        [        S/UQ76 U l	        S	T< S
3U l
        gs  snnf ! [         a  nU4S jnXl         SnAN?SnAff = f)z%Initialise the glut callback instancec                     SU-  $ )Nz(int) %s )typnames     r"   describe'GLUTCallback.__init__.<locals>.describee   s    t$$r$   zSpecify handler for GLUT z events
    def handler( z, z ):
        return None
glut%sFuncc                  L   > SSK Jn  UR                  " ST< SST-  < S35      e)Nr   )r   z!Undefined GLUT callback function z, check for bool(r8   z) before calling)OpenGLr   NullFunctionError)argsnamedr   typeNames      r"   failFunction+GLUTCallback.__init__.<locals>.failFunctionp   s(    (-- ,"9 r$   NglutFunc)r>   joinzip__doc__getattrr
   wrappedOperationAttributeErrorFUNCTION_TYPEcallbackTypeCONTEXT_DATA_KEY)	selfr>   parameterTypesparameterNamesr6   r4   r5   errr?   s	    `       r"   __init__GLUTCallback.__init__b   s     	% "499!>C.
C
 c C.
 $
	1$+T<3J$LD! *4B.B.6 9!.
  	1 %1!!	1s   BB 
B,B''B,)functionc                   ^ ^ [         (       a  [        TS5      (       a
  UU 4S jnUnOTn[        US5      (       a  T R                  U5      nOTn[        R                  " T R
                  U5        T R                  " U/UQ76   U$ )N__call__c                  J  >  [        5       (       d  [        S5      eT" U 0 UD6$ ! [         as  n[        R                  " 5         [
        R                  R                  STR                  < ST< SU < SU< SU< S35        [        R                  " S5         S	nAg	S	nAff = f)
z0Safe calling of GUI callbacks, exits on failureszNo valid context!zGLUT z
 callback z with ,z failed: returning None 
   N)r   RuntimeError	Exception	traceback	print_excsysstderrwriter>   os_exit)r<   r=   rO   rR   rL   s      r"   safeCall'GLUTCallback.__call__.<locals>.safeCall}   s~    	 022*,CEE#d5e55   '')JJ$$xuc'  HHQKK s   !% 
B"A)BB")r   hasattrrJ   r   setValuerK   rG   )rL   rR   r<   rb   finalFunction	cCallbacks   ``    r"   rT   GLUTCallback.__call__{   sy    GXj$B$B  %M$MM*..))=:I I 	d33Y@y141r$   )rK   rE   rJ   r>   rG   N)	__name__
__module____qualname____firstlineno__rE   rP   r   rT   __static_attributes__r3   r$   r"   r/   r/   `   s    A:0 Hr$   r/   c                       \ rS rSrSrS rSrg)GLUTTimerCallback   zFGLUT timer callbacks (completely nonstandard wrt other GLUT callbacks)c                 D  ^ ^^^ T R                  T5      n[        R                  " T R                  5      mTc#  / m[        R                  " T R                  T5        UUUU 4S jmT R                  T5      nTUl        TR                  U5        T R                  XU5        U$ )Nc                   >  T" U 5        T H,  nUR                   TL d  M  TR                  U5        S Ul           O   T(       d!  [        R                  " TR                  5        g g ! T H,  nUR                   TL d  M  TR                  U5        S Ul           O   T(       d!  [        R                  " TR                  5        f f = f)N)rR   remover   delValuerK   )valueitem	callbacks
deregisterrR   rL   s     r"   rx   .GLUTTimerCallback.__call__.<locals>.deregister   s    	B%!%D}}
2!(($0(,	 &
 !(($*?*?A ! &D}}
2!(($0(,	 &
 !(($*?*?A !s   A& &C=AC)rJ   r   getValuerK   re   rR   appendrG   )rL   millisecondsrR   ru   rg   rw   rx   s   ` `  @@r"   rT   GLUTTimerCallback.__call__   s    %%x1	
  (($*?*?A	I  $"7"7D
	B 
	B %%z3	'	)%|?r$   r3   N)ri   rj   rk   rl   rE   rT   rm   r3   r$   r"   ro   ro      s
    Pr$   ro   c                       \ rS rSrSr\" \R                  \R                  5      rS r	S/\	l
        \" \	5      r	S rS/\l
        \" \5      rSrg)	GLUTMenuCallback   z8Place to collect the GLUT Menu manipulation special codec                     U R                  U5      n[        R                  " U5      n[        R                  " SU4X!45        U$ )zCreate a new (current) menu, return small integer identifier

func( int ) -- Function taking a single integer reflecting
    the user's choice, the value passed to glutAddMenuEntry

return menuID (small integer)
menucallback)rJ   _simpler(   r   re   )clsfuncrg   menus       r"   r(   GLUTMenuCallback.glutCreateMenu   sA     $$d,	%%y2~d3i5EGr$   r   c                 b    [         R                  " U5      n[        R                  " SU45        U$ )zgDestroy (cleanup) the given menu

Deregister's the interal pointer to the menu callback 

returns None
r   )r   glutDestroyMenur   rt   )r   r   results      r"   r    GLUTMenuCallback.glutDestroyMenu   s,     (($0~d35r$   r   r3   N)ri   rj   rk   rl   rE   rI   ctypesc_intrJ   r(   r   classmethodr   rm   r3   r$   r"   r   r      sO    B &,,>L !'jN .2N	 "(zO!?4Or$   r   	ButtonBox)buttonstateDials)dialru   Displayr3   Entry)r   IdleJoystick)
buttonMaskxyzKeyboard)keyr   r   
KeyboardUp
MenuStatus)statusr   r   	MenuState)r   Motion)r   r   Mouse)r   r   r   r   OverlayDisplayPassiveMotionReshape)widthheightSpaceballButtonSpaceballMotion)r   r   r   SpaceballRotateSpecial	SpecialUpTabletButtonTabletMotion
VisibilityWindowStatusTimer)ru   Fc                  n   [         (       a  U $ Sq U (       a  U S   U SS pSn[        U[        5      (       a2  UnU[        U 5      :w  a   [	        SU< S[        U 5      < SU < 35      eO?[        U[
        [        45      (       a  U4U -   n [        U 5      nOUn [        U 5      nOSn/ n U  Vs/ s H  n[        U5      PM     n nU(       d  S[        S5      /p[        R                  [        U 5      -  " 5       n[        U 5       H	  u  pQXU'   M     [        R                  " U5      nSSKnUR                  " 5       n [        [        R                  " U5      U5        UR                   " U5        [#        UR$                  5       Vs/ s H  oTU   PM	     sn$ s  snf ! UR                   " U5        f = fs  snf )	zInitialise the GLUT libraryTr   rX   NzSpecified count of z does not match length (z) of argument list foo)INITIALIZED
isinstancer   len
ValueErrorr   r   r   r   c_char_p	enumerater   r`   getcwdr#   byrefchdirrangeru   )r<   argcountr   holderir`   currentDirectorys           r"   r)   r)   (  s    {K748Dc=))ED	! 3t9d#   " uWo..6$;DIEDIE!%&AHQKD&(5/*tooD	),F4q	 !LL%!Eyy{%U+V5
"$ %++//aq	/  ' 	"$s   ,F< F F2F/c                 &   Sn [         R                  U 5        [        R                  " 5       n[        R                  " U5      n[
        R                  SX5        [        U 5      $ ! [         a!  n[
        R                  SU W5         SnAN1SnAff = f)z9Want to destroy the window, we need to do some cleanup...r   z*Cleaning up context data for window %s: %sz@Error attempting to clean up context data for GLUT window %s: %sN)
r
   glutSetWindowr   
getContextcleanupContext_loginforZ   r   _base_glutDestroyWindow)windowcontextr   rO   s       r"   r-   r-   U  s    Gm6"((*++W6		CVU #F,,  m

Z\bdjllms   AA% %
B/BB)RrE   OpenGL.platformr   r   r   r
   r:   r   r   r   r	   
OpenGL.rawr   OpenGL._bytesr   r   r   r   r`   r]   r[   CALLBACK_FUNCTION_TYPErI   r   r   getLogr   r5   r   r   _exitfunctypecreateBaseFunctionPOINTERr   r   r   r   exitr!   r#   r&   r(   nullFunctionri   rF   r   objectr/   ro   r   r   glutButtonBoxFuncglutDialsFuncglutDisplayFuncglutEntryFuncglutIdleFuncc_uintglutJoystickFuncc_charglutKeyboardFuncglutKeyboardUpFuncglutMenuStatusFuncglutMenuStateFuncglutMotionFuncglutMouseFuncglutOverlayDisplayFuncglutPassiveMotionFuncglutReshapeFuncglutSpaceballButtonFuncglutSpaceballMotionFuncglutSpaceballRotateFuncglutSpecialFuncglutSpecialUpFuncglutTabletButtonFuncglutTabletMotionFuncglutVisibilityFuncglutWindowStatusFuncglutTimerFuncr   r)   rG   r-   r3   r$   r"   <module>r      s  , R Q}} 5 5 & 1 1 ! !.. -{{)+77d?IIEG!47M!44("3"3"8"8T...v~~foo/N}]N"	 "*!<!<$(*;*;*@*@V\\//-08	"  (::"(9(9(>(>6<<fll3MBM	  chh'I:<= **D...v~~v/PQ+8HN "$(;TB 5F 5l :5 5< "00"22 !&,,v||,.@  fll6<<(*: r2 fll_j 
B  v||FLLFHb   v||FLL9?  "6==fll;_  "6<<V\\:<N  !&,,+  v||FLL)9 fll6<<V\\BD^ &b"  %fll6<<0)  V\\*,> 'V\\24F  'V\\&,,?  'V\\&,,?  V\\&,,7 !&,,v||FLL9?  $V\\&,,v||FLLIKf  $V\\&,,v||FLLIKf  $V\\&,,/  "6<</:  $V\\OZ 
 "fll_j *V $,, 
- &-%>%>  "r$   