
    3j%                        S r SSKr\R                  " S5      rSSKJrJr  SSKJr  Sr	 " S S\
5      r " S	 S
\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r\R&                  (       a/  SSKJr  Sr\R,                  (       a   SSKJr  \c   " S S\5      rOSr\r\r\rg! \ a  r\R5                  S5         SrCN4SrCff = f)a  Implementation of OpenGL errors/exceptions

Note that OpenGL-ctypes will also throw standard errors,
such as TypeError or ValueError when appropriate.

ErrorChecker is an _ErrorChecker instance that allows you
to register a new error-checking function for use 
throughout the system.
    NzOpenGL.error)platform_configflags)ArgumentError)ErrorGLErrorGLUError	GLUTErrorGLerrorGLUerror	GLUTerrorr   c                       \ rS rSrSrSrg)r      z6Base class for all PyOpenGL-specific exception classes N__name__
__module____qualname____firstlineno____doc____static_attributes__r       F/home/wildlama/miniconda3/lib/python3.13/site-packages/OpenGL/error.pyr   r      s    @r   r   c                       \ rS rSrSrSrg)	NoContext   a;  Raised to indicate that there is no currently active context

Technically almost *any* OpenGL call can segfault if there is 
no active context.  The OpenGL.CHECK_CONTEXT flag, if enabled 
will cause this error to be raised whenever a GL or GLU call is 
issued (via PyOpenGL) if there is no currently valid context.
r   Nr   r   r   r   r   r      s    r   r   c                       \ rS rSrSrSrg)	CopyError   zRaised to indicate that operation requires data-copying

if you set:
    OpenGL.ERROR_ON_COPY = True 

before importing OpenGL.GL, this error will be raised when 
a passed argument would require a copy to be made.
r   Nr   r   r   r   r   r      s    r   r   c                       \ rS rSrSrSrg)NullFunctionError'   z1Error raised when an undefined function is calledr   Nr   r   r   r   r    r    '   s    ;r   r    c                   V    \ rS rSrSr       SS jrSrS rS rS r	SS	 jr
S
 rSrg)r   *   a  OpenGL core error implementation class

Primary purpose of this error class is to allow for 
annotating an error with more details about the calling 
environment so that it's easier to debug errors in the
wrapping process.

Attributes:

    err -- the OpenGL error code for the error 
    result -- the OpenGL result code for the operation
    baseOperation -- the "function" being called
    pyArgs -- the translated set of Python arguments
    cArgs -- the Python objects matching 1:1 the C arguments
    cArguments -- ctypes-level arguments to the operation,
        often raw integers for pointers and the like
    description -- OpenGL description of the error (textual)
Nc                 h    XUXEUU4u  U l         U l        U l        U l        U l        U l        U l        g)z:Initialise the GLError, storing metadata for later displayN)errresult
cArgumentsbaseOperationpyArgscArgsdescription)selfr%   r&   r'   r(   r)   r*   r+   s           r   __init__GLError.__init__=   s<      5
		
Hdk4?TZr   )r%   r+   r(   r)   r*   r'   r&   c                    / nU R                    Hx  n[        XS5      nUc  US:X  d  M  SU-  n[        X5      (       a"  UR                  [        X5      " X#5      5        MQ  UR                  U< SU R	                  U5      < 35        Mz     U R
                  R                  < SSR                  U Vs/ s H  oU(       d  M  UPM     sn5      < S3$ s  snf )z4Create a fully formatted representation of the errorNr+   z	format_%s = z(
	z,
	z
))DISPLAY_ORDERgetattrhasattrappend	shortRepr	__class__r   join)r,   argspropertyvalueformatFunctionxs         r   __str__GLError.__str__Z   s    **HTT3E Hm$;!,h!7D22KK!=x!PQKK /"  +  $~~66"1Q"9
  	"s   2
C Cc           
      F   U R                   R                  < SSR                  SU R                  -  U R	                  SU R
                  5      =(       d    SU R                  SU R                  5      =(       d    S4 Vs/ s H  nU(       d  M  UPM     sn5      < S3$ s  snf )z7Produce a much shorter version of the error as a stringz( z, zerr=%sr+    r(   z ))r6   r   r7   r%   format_descriptionr+   format_baseOperationr(   )r,   r<   s     r   __repr__GLError.__repr__k   s     NN##II$((#''8H8HJPb))?D<N<NPVTV#  #Q 	  #  
 	
s   >BBc                     Uc-  U R                   b    SSKJn  U" U R                   5      =U l        nUc  gU< SU R                  U5      < 3$ ! [         a
  n SnAgSnAff = f)z-Format description using GLU's gluErrorStringNr   )gluErrorStringr0   )r%   
OpenGL.GLUrF   r+   	Exceptionr5   )r,   r9   r:   rF   r%   s        r   rA   GLError.format_descriptionu   sf    =TXX15+9488+EE 5 =NNE#
 	
	  s   A 
A!A!c           
      d   [        U[        [        45      (       am  U(       af  [        [	        U5      5      S:  aN  [        U[        5      (       a  SnOSnUSR                  U Vs/ s H  o@R                  US5      PM     sn5      -  $ [	        U5      n[        U5      S:  a  U$ USS S	-   $ s  snf )
z0Retrieve short representation of the given value(   z	[
		%s
	]z
(
		%s,
	)z,
		Fx   Nu   z...)
isinstancelisttuplelenreprr7   r5   )r,   r:   
firstLeveltemplater<   rs         r   r5   GLError.shortRepr   s    utEl,,3tE{;KR;O5$((+,inn5:5:NN1U+U  
 %Mq6C<HTc7U?"s   %B-
c                 \    [        US5      (       a  U< SUR                  < 3$ U< SU< 3$ )z,Format a baseOperation reference for displayr   r0   )r3   r   )r,   r9   r:   s      r   rB   GLError.format_baseOperation   s)    E:'''99'00r   )r(   r*   r'   r+   r%   r)   r&   )NNNNNNN)T)r   r   r   r   r   r-   r1   r=   rC   rA   r5   rB   r   r   r   r   r   r   *   sC    ( 
(M"	

#"1r   r   c                       \ rS rSrSrSrg)r      zGLU error implementation classr   Nr   r   r   r   r   r          (r   r   c                       \ rS rSrSrSrg)r	      zGLUT error implementation classr   Nr   r   r   r   r	   r	      s    )r   r	   c                       \ rS rSrSrSrg)EGLError   zEGL error implementation classr   Nr   r   r   r   r_   r_      r[   r   r_   )acceleratesupport)_ErrorCheckerzYOpenGL_accelerate seems to be installed, but unable to import error checking entry point!c                   X    \ rS rSrSrSrSS\4S jrS rS r	S r
  SS	 jrS
 rS rSrg)rb      zPer-API error-checking object

Attributes:
    _registeredChecker -- the checking function enabled when 
        not doing onBegin/onEnd processing
    _currentChecker -- currently active checking function
Nr   c                 "   UR                   U l        X l        X0l        X@l        U R                  (       a9  [
        R                  (       a  U R                  U l        O#U R                  U l        OU R                  U l        U R                  U l
        g)z+Initialize from a platform module/referenceN)CurrentContextIsValid_isValid
_getErrors_noErrorResult_errorClassr   CONTEXT_CHECKINGsafeGetError_registeredCheckernullGetError_currentChecker)r,   r   r(   noErrorResult
errorClasss        r   r-   _ErrorChecker.__init__   sf     ( > >"/&3##- ??#44262C2C/26///.2.?.?D+'+'>'>$r   c                 8    U R                   U R                  L a  gg)z(We are "true" if we actually do anythingFT)rm   rn   r,   s    r   __bool___ErrorChecker.__bool__   s    **d.?.?? r   c                 N    U R                  5       (       a  U R                  5       $ g)z5Check for error, testing for context before operationN)rg   rh   rt   s    r   rl   _ErrorChecker.safeGetError   s    ==????,,r   c                     U R                   $ )z;Used as error-checker when no error checking should be done)ri   rt   s    r   rn   _ErrorChecker.nullGetError   s    ***r   c                 h    U R                  5       nXPR                  :w  a  U R                  UUUUS9eU$ )a  Base GL Error checker compatible with new ctypes errcheck protocol

This function will raise a GLError with just the calling information
available at the C-calling level, i.e. the error code, cArguments,
baseOperation and result.  Higher-level code is responsible for any 
extra annotations.

Note:
    glCheckError relies on glBegin/glEnd interactions to 
    prevent glGetError being called during a glBegin/glEnd 
    sequence.  If you are calling glBegin/glEnd in C you 
    should call onBegin and onEnd appropriately.
)r'   r(   )ro   ri   rj   )r,   r&   r(   r'   r8   r%   s         r   glCheckError_ErrorChecker.glCheckError   sI    ( **,---**%/(5	 +   r   c                 &    U R                   U l        g)z?Called by glBegin to record the fact that glGetError won't workN)rn   ro   rt   s    r   onBegin_ErrorChecker.onBegin   s    '+'8'8$r   c                 &    U R                   U l        g)z<Called by glEnd to record the fact that glGetError will workN)rm   ro   rt   s    r   onEnd_ErrorChecker.onEnd   s    '+'>'>$r   )ro   rj   rh   rg   ri   rm   )NN)r   r   r   r   r   rh   r   r-   ru   rl   rn   r|   r   r   r   r   r   r   rb   rb      sA     J8<AZa ?

+ #	:9?r   rb   )r   logging	getLogger_logOpenGLr   r   ctypesr   __all__rH   r   r   r   r    r   r   r	   r_   ERROR_CHECKINGra   rb   ACCELERATE_AVAILABLEOpenGL_accelerate.errorcheckerImportErrorr%   warningobjectr   r
   r   r   r   r   <module>r      s	   .* )  
AY A  < <o1u o1b) )* *) ) (M--	|D F	?V F	?P M
	_  	|LLy{{	|s   ,C
 
C+C&&C+