
    3j#                     \   S r SSKr\R                  " \5      rSSKJr  SSKJrJ	r	J
r
JrJrJrJr  SSKJr  SSKJrJrJr  / SQrS rS	/r\\	\
\\4 H  r\" \5       Hr  rSrS
 HC  r\R;                  \5      (       d  M  Sr\S\" \5      *  r\\;  d  M1  \" \\5      (       d  MA  Sr  O   \SL d  MU  \RA                  S\R                  \5        Mt     M     \" \RB                  \RD                  5      r!\" \RF                  \RH                  5      r#\" \RJ                  \RL                  5      r%\" \RN                  \RP                  5      r'\" \RR                  \RT                  5      r)\" \RV                  \RT                  5      r+\" \RX                  \RZ                  5      r,\" \R\                  \RZ                  5      r.\R^                  r/\R`                  r0\Rb                  r1\Rd                  r2\Rf                  r3 " S S\45      r5S r6S r7 " S S\85      r9 " S S\85      r: " S S\85      r;g)ay  Convenience module providing common shader entry points

The point of this module is to allow client code to use
OpenGL Core names to reference shader-related operations
even if the local hardware only supports ARB extension-based
shader rendering.

There are also two utility methods compileProgram and compileShader
which make it easy to create demos which are shader-using.
    N)GL)shader_objectsfragment_shadervertex_shadervertex_programgeometry_shader4separate_shader_objectsget_program_binary)	alternate)bytesunicodeas_8_bit)glAttachShaderglDeleteShaderglGetProgramInfoLogglGetShaderInfoLogglGetProgramivglGetShaderivcompileProgramcompileShaderGL_VALIDATE_STATUSGL_LINK_STATUSShaderCompilationErrorShaderValidationErrorShaderLinkErrorc                 H   [        [        U 5      (       a  [        [        U 5      n[        US5      (       aI  [        [        [        U 5      [        [        U5      5      [        5       U '   [        R                  U 5        gU[        5       U '   [        R                  U 5        gg)N__call__TF)hasattrr   getattrr   moduleglobals__all__append)basenameroots      K/home/wildlama/miniconda3/lib/python3.13/site-packages/OpenGL/GL/shaders.py_altr(   &   s~    DD"4
##'4 t$GIdO NND"  #GIdONND"    r   )	ObjectARB_ARBARBFTzFound no alternate for: %s.%sc                   D    \ rS rSrSrSrS rS rS rS r	S r
SS	 jrS
rg)ShaderProgramY   z0Integer sub-class with context-manager operationFc                     [        U 5        g)zStart use of the programNglUseProgram)selfs    r'   	__enter__ShaderProgram.__enter__\   s
    dr)   c                     [        S5        g)zStop use of the programr   Nr1   )r3   typvaltbs       r'   __exit__ShaderProgram.__exit___   s
    ar)   c                     [        U 5        [        U [        5      nU[        :X  a  [	        SU< S[        U 5      < 35      eSU l        U $ )z|Check that the program validates

Validation has to occur *after* linking/loading

raises ShaderValidationError on failures
zValidation failure (): T)glValidateProgramr   r   GL_FALSEr   r   	validated)r3   
validations     r'   check_validateShaderProgram.check_validatec   sL     	4!#T+=?
!'#T+ 
 r)   c                 r    [        U [        5      nU[        :X  a  [        SU< S[	        U 5      < 35      eU $ )zGCheck link status for this program

raises ShaderLinkError on failures
zLink failure (r=   )r   r   r?   r   r   )r3   link_statuss     r'   check_linkedShaderProgram.check_linkedu   s<    
 %dN<("!#T+ 
 r)   c                    SSK JnJn  SSKJn  U" 5       n[        U [        R                  U5        UR                  UR                  45      nU" 5       nU" 5       n[        R                  " XR                  XgU5        UR                  U4$ )a  Attempt to retrieve binary for this compiled shader

Note that binaries for a program are *not* generally portable,
they should be used solely for caching compiled programs for 
local use; i.e. to reduce compilation overhead.

returns (format,binaryData) for the shader program
r   )GLintGLenum)GLbyteArray)OpenGL.raw.GL._typesrI   rJ   OpenGL.arraysrK   r   r
   GL_PROGRAM_BINARY_LENGTHzerosvalueglGetProgramBinary)r3   rI   rJ   rK   sizeresultsize2formats           r'   retrieveShaderProgram.retrieve   sn     	6-w0II4Q""TZZM2--tZZPVX||V##r)   c                     [         R                  " XU[        U5      5        U(       a  U R                  5         U R	                  5         U $ )zOAttempt to load binary-format for a pre-compiled shader

See notes in retrieve
)r
   glProgramBinarylenrB   rF   )r3   rU   binaryvalidates       r'   loadShaderProgram.load   s:    
 	**D&#f+N!r)   )r@   N)T)__name__
__module____qualname____firstlineno____doc__r@   r4   r:   rB   rF   rV   r]   __static_attributes__ r)   r'   r.   r.   Y   s(    :I$$$	r)   r.   c                     [        5       nUR                  S5      (       a  [        U[        R                  [
        5        UR                  S5      (       a  [        U[        R                  [
        5        U  H  n[        X#5        M     [        U5      n[        U5        UR                  SS5      (       a  UR                  5         UR                  5         U  H  n[        U5        M     U$ )a  Create a new program, attach shaders and validate

shaders -- arbitrary number of shaders to attach to the
    generated program.
separable (keyword only) -- set the separable flag to allow 
    for partial installation of shader into the pipeline (see 
    glUseProgramStages)
retrievable (keyword only) -- set the retrievable flag to 
    allow retrieval of the program binary representation, (see 
    glProgramBinary, glGetProgramBinary)
validate (keyword only) -- if False, suppress automatic 
    validation against current GL state. In advanced usage 
    the validation can produce spurious errors. Note: this 
    function is *not* really intended for advanced usage,
    if you're finding yourself specifying this flag you 
    likely should be using your own shader management code.

This convenience function is *not* standard OpenGL,
but it does wind up being fairly useful for demos
and the like.  You may wish to copy it to your code
base to guard against PyOpenGL changes.

Usage:

    shader = compileProgram(
        compileShader( source, GL_VERTEX_SHADER ),
        compileShader( source2, GL_FRAGMENT_SHADER ),
    )
    glUseProgram( shader )

Note:
    If (and only if) validation of the linked program
    *passes* then the passed-in shader objects will be
    deleted from the GL.

returns ShaderProgram() (GLuint) program reference
raises RuntimeError subclasses {
    ShaderCompilationError, ShaderValidationError, ShaderLinkError,
} when a link/validation failure occurs
	separableretrievabler\   T)glCreateProgramgetglProgramParameterir	   GL_PROGRAM_SEPARABLEGL_TRUEr
   "GL_PROGRAM_BINARY_RETRIEVABLE_HINTr   r.   glLinkProgramrB   rF   r   )shadersnamedprogramshaders       r'   r   r      s    R GyyW&=&R&RT[]yyW&8&[&[]dfw' W&G'yyT"" v Nr)   c                 .   [        U [        [        45      (       a  U /n U  Vs/ s H  n[        U5      PM     n n[	        U5      n[        X05        [        U5        [        U[        5      nU(       d  [        SU< S[        U5      < 3U U5      eU$ s  snf )zCompile shader source of given type

source -- GLSL source-code for the shader
shaderType -- GLenum GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, etc,

returns GLuint compiled shader reference
raises RuntimeError when a compilation failure occurs
zShader compile failure (r=   )
isinstancer   r   r   glCreateShaderglShaderSourceglCompileShaderr   GL_COMPILE_STATUSr   r   )source
shaderTypesrs   rS   s        r'   r   r      s     6E'?++$*,Fqx{FF,J'FF$VF$57F %"F, 
 	
 M! -s   Bc                       \ rS rSrSrSrg)r      z&Raised when a shader compilation failsre   Nr_   r`   ra   rb   rc   rd   re   r)   r'   r   r      s    0r)   r   c                       \ rS rSrSrSrg)r      z'Raised when a program fails to validatere   Nr   re   r)   r'   r   r      s    1r)   r   c                       \ rS rSrSrSrg)r      zRaised when a shader link failsre   Nr   re   r)   r'   r   r      s    )r)   r   )<rc   logging	getLoggerr_   logOpenGLr   OpenGL.GL.ARBr   r   r   r   r   r	   r
   OpenGL.extensionsr   OpenGL._bytesr   r   r   r"   r(   	_excludesr    dirr%   foundsuffixendswithrZ   r$   debugr   glAttachObjectARBglDetachShaderglDetachObjectARBr   glDeleteObjectARBglGetAttachedShadersglGetAttachedObjectsARBr   glGetInfoLogARBr   r   glGetObjectParameterivARBr   r   ry   r   r?   rm   intr.   r   r   RuntimeErrorr   r   r   re   r)   r'   <module>r      s%  	 #    ( 0 0" 	?=F F0F}}f&&Os6{^,y(T4)) $ 1 E>II: 	& B--n.N.NPB--n.N.NPB--n.N.NP ""9"9>;a;ac !7!79W9WY  5 5~7U7UW 2++^-U-UWB--~/W/WY** (( "";;
**ES EN7p:1\ 12L 2*l *r)   