#NEWLINE# def _process_shader_template( self , template_src , cache_key , injections ) : #NEWLINE# #INDENT# ' Generates a compiled shader object from a given shader\n        source location and code injection definitions. ' #NEWLINE# with open ( template_src , 'r' ) as handle : #NEWLINE# #INDENT# shader_lines = handle . readlines ( ) #NEWLINE# #UNINDENT# parsed_lines = [ '\n\n' ] #NEWLINE# parsed_lines . append ( '/* Compiled Shader Template' ) #NEWLINE# parsed_lines . append ( ( ( " * generated from: '" + template_src ) + "'" ) ) #NEWLINE# parsed_lines . append ( ( ( " * cache key: '" + cache_key ) + "'" ) ) #NEWLINE# parsed_lines . append ( ' *' ) #NEWLINE# parsed_lines . append ( ' * !!! Autogenerated, do not edit! Your changes will be lost. !!!' ) #NEWLINE# parsed_lines . append ( ' */\n\n' ) #NEWLINE# in_main = False #NEWLINE# for line in shader_lines : #NEWLINE# #INDENT# stripped_line = line . strip ( ) . lower ( ) #NEWLINE# if ( 'void main()' in stripped_line ) : #NEWLINE# #INDENT# in_main = True #NEWLINE# #UNINDENT# if ( stripped_line . startswith ( '%' ) and stripped_line . endswith ( '%' ) ) : #NEWLINE# #INDENT# hook_name = stripped_line [ 1 : ( - 1 ) ] #NEWLINE# indent = ( ' ' * ( len ( line ) - len ( line . lstrip ( ) ) ) ) #NEWLINE# if ( hook_name in injections ) : #NEWLINE# #INDENT# insertions = injections . pop ( hook_name ) #NEWLINE# if ( len ( insertions ) > 0 ) : #NEWLINE# #INDENT# header = ( ( ( ( indent + '/* Hook: ' ) + hook_name ) + ' */' ) + ( ' {' if in_main else '' ) ) #NEWLINE# parsed_lines . append ( header ) #NEWLINE# for line_to_insert in insertions : #NEWLINE# #INDENT# if ( line_to_insert is None ) : #NEWLINE# #INDENT# self . warn ( ( ( "Empty insertion '" + hook_name ) + "'" ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# if ( not isinstance ( line_to_insert , str ) ) : #NEWLINE# #INDENT# self . warn ( 'Invalid line type: ' , line_to_insert ) #NEWLINE# continue #NEWLINE# #UNINDENT# if line_to_insert . startswith ( '#' ) : #NEWLINE# #INDENT# parsed_lines . append ( line_to_insert ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# parsed_lines . append ( ( indent + line_to_insert ) ) #NEWLINE# #UNINDENT# #UNINDENT# if in_main : #NEWLINE# #INDENT# parsed_lines . append ( ( indent + '}' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# parsed_lines . append ( line . rstrip ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# parsed_lines . append ( '' ) #NEWLINE# for key in injections : #NEWLINE# #INDENT# self . warn ( ( ( ( ( "Hook '" + key ) + "' not found in template '" ) + template_src ) + "'!" ) ) #NEWLINE# #UNINDENT# shader_content = '\n' . join ( parsed_lines ) #NEWLINE# temp_path = ( ( '/$$rptemp/$$effect-' + cache_key ) + '.glsl' ) #NEWLINE# with open ( temp_path , 'w' ) as handle : #NEWLINE# #INDENT# handle . write ( shader_content ) #NEWLINE# #UNINDENT# return temp_path