# Path: PyOpenGLng/HighLevelApi/Shader.py
# class GlShaderManager(with_metaclass(SingletonMetaClass, object)):
# 
#     """ This class provides a shader manager where each shader or program are identified by a name
#     and the shader sources are loaded from files.
# 
#     The shaders or programs can be accessed using an attribute or a dictionary interface. For
#     example to get the shader *fixed_fragment* we can use either::
# 
#       shader_manager.fixed_fragment
#       shader_manager.['fixed_fragment']
# 
#     We can test if an identifier exists using::
# 
#       'fixed_fragment' in shader_manager
#     """
# 
#     # Fixme: -> attributeDictionaryInterface
# 
#     ##############################################
# 
#     def __init__(self):
# 
#         self._shaders = {}
#         self._programs = {}
# 
#     ##############################################
# 
#     def __contains__(self, name):
# 
#         return name in self._shaders or name in self._programs
# 
#     ##############################################
# 
#     def __getattr__(self, name):
# 
#         item = self._programs.get(name, None)
#         if item is None:
#             item = self._shaders.get(name, None)
#             if item is None:
#                 raise KeyError(name)
# 
#         return item
# 
#     ##############################################
# 
#     __getitem__ = __getattr__
# 
#     ##############################################
# 
#     def has_visual(self):
# 
#         return bool(GL.glCreateShader)
# 
#     ##############################################
# 
#     def load_from_file(self, shader_name, shader_file_name):
# 
#         """ Load a shader from a source file and compile it. This shader is identified by
#         *shader_name*.
#         """
# 
#         if shader_name in self:
#             raise NameError("Shader %s is already defined" % (shader_name))
# 
#         shader = GlShader(file_name=shader_file_name)
#         shader.compile()
#         self._shaders[shader_name] = shader
# 
#         return shader
# 
#     ##############################################
# 
#     def link_program(self, program_name, shader_list,
#                      program_interface=None,
#                      shader_program_class=GlShaderProgram,
#                      shader_program_args=(),
#                      ):
# 
#         """ Link a program with the given list of shader names. This program is identified by
#         *shader_name*.  The argument *program_interface* can be used to set the program interface.
#         """
# 
#         if program_name in self:
#             raise NameError("Program %s is already defined" % (program_name))
# 
#         shader_program = shader_program_class(program_name, *shader_program_args)
#         for shader_name in shader_list:
#             shader_program.attach_shader(self[shader_name])
#         # Fixme: move to link ?
#         if program_interface is not None:
#             shader_program.set_program_interface(program_interface)
#         shader_program.link()
#         if program_interface is not None:
#             shader_program.set_uniform_block_bindings()
#         self._programs[program_name] = shader_program
# 
#         return shader_program
# 
# class GlShaderProgramInterface(object):
# 
#     """ This class defines a programming interface for a program.
#     """
# 
#     ##############################################
# 
#     def __init__(self, uniform_blocks, attributes):
# 
#         self._init_uniform_blocks(uniform_blocks)
#         self._init_attributes(attributes)
# 
#     ##############################################
# 
#     def _init_uniform_blocks(self, uniform_blocks):
# 
#         self.uniform_blocks = AttributeDictionaryInterface()
#         for binding_point, name in enumerate(uniform_blocks):
#             pair = GlShaderProgramInterfaceUniformBlock(name, binding_point)
#             self.uniform_blocks._dictionary[name] = pair
# 
#     ##############################################
# 
#     def _init_attributes(self, attributes):
# 
#         self.attributes = AttributeDictionaryInterface()
#         for location, name in enumerate(attributes):
#             pair = GlShaderProgramInterfaceAttribute(name, location)
#             self.attributes._dictionary[name] = pair


import os
from PyOpenGLng.HighLevelApi.Shader import GlShaderManager, GlShaderProgramInterface
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# 
####################################################################################################

####################################################################################################


####################################################################################################


####################################################################################################

class ConfigPath(object):

    module_path = os.path.dirname(__file__)

    ##############################################

    @staticmethod
    def glsl(file_name):

        return os.path.join(ConfigPath.module_path, 'glslv3', file_name)

####################################################################################################

shader_manager = GlShaderManager()

position_shader_program_interface = GlShaderProgramInterface(uniform_blocks=('viewport',),
                                                             attributes=('position',))


# Path: PyOpenGLng/HighLevelApi/Shader.py
# class GlShaderManager(with_metaclass(SingletonMetaClass, object)):
# 
#     """ This class provides a shader manager where each shader or program are identified by a name
#     and the shader sources are loaded from files.
# 
#     The shaders or programs can be accessed using an attribute or a dictionary interface. For
#     example to get the shader *fixed_fragment* we can use either::
# 
#       shader_manager.fixed_fragment
#       shader_manager.['fixed_fragment']
# 
#     We can test if an identifier exists using::
# 
#       'fixed_fragment' in shader_manager
#     """
# 
#     # Fixme: -> attributeDictionaryInterface
# 
#     ##############################################
# 
#     def __init__(self):
# 
#         self._shaders = {}
#         self._programs = {}
# 
#     ##############################################
# 
#     def __contains__(self, name):
# 
#         return name in self._shaders or name in self._programs
# 
#     ##############################################
# 
#     def __getattr__(self, name):
# 
#         item = self._programs.get(name, None)
#         if item is None:
#             item = self._shaders.get(name, None)
#             if item is None:
#                 raise KeyError(name)
# 
#         return item
# 
#     ##############################################
# 
#     __getitem__ = __getattr__
# 
#     ##############################################
# 
#     def has_visual(self):
# 
#         return bool(GL.glCreateShader)
# 
#     ##############################################
# 
#     def load_from_file(self, shader_name, shader_file_name):
# 
#         """ Load a shader from a source file and compile it. This shader is identified by
#         *shader_name*.
#         """
# 
#         if shader_name in self:
#             raise NameError("Shader %s is already defined" % (shader_name))
# 
#         shader = GlShader(file_name=shader_file_name)
#         shader.compile()
#         self._shaders[shader_name] = shader
# 
#         return shader
# 
#     ##############################################
# 
#     def link_program(self, program_name, shader_list,
#                      program_interface=None,
#                      shader_program_class=GlShaderProgram,
#                      shader_program_args=(),
#                      ):
# 
#         """ Link a program with the given list of shader names. This program is identified by
#         *shader_name*.  The argument *program_interface* can be used to set the program interface.
#         """
# 
#         if program_name in self:
#             raise NameError("Program %s is already defined" % (program_name))
# 
#         shader_program = shader_program_class(program_name, *shader_program_args)
#         for shader_name in shader_list:
#             shader_program.attach_shader(self[shader_name])
#         # Fixme: move to link ?
#         if program_interface is not None:
#             shader_program.set_program_interface(program_interface)
#         shader_program.link()
#         if program_interface is not None:
#             shader_program.set_uniform_block_bindings()
#         self._programs[program_name] = shader_program
# 
#         return shader_program
# 
# class GlShaderProgramInterface(object):
# 
#     """ This class defines a programming interface for a program.
#     """
# 
#     ##############################################
# 
#     def __init__(self, uniform_blocks, attributes):
# 
#         self._init_uniform_blocks(uniform_blocks)
#         self._init_attributes(attributes)
# 
#     ##############################################
# 
#     def _init_uniform_blocks(self, uniform_blocks):
# 
#         self.uniform_blocks = AttributeDictionaryInterface()
#         for binding_point, name in enumerate(uniform_blocks):
#             pair = GlShaderProgramInterfaceUniformBlock(name, binding_point)
#             self.uniform_blocks._dictionary[name] = pair
# 
#     ##############################################
# 
#     def _init_attributes(self, attributes):
# 
#         self.attributes = AttributeDictionaryInterface()
#         for location, name in enumerate(attributes):
#             pair = GlShaderProgramInterfaceAttribute(name, location)
#             self.attributes._dictionary[name] = pair


# Path: examples/high-level-api-demo/ShaderProgramesV3.py
import os
from PyOpenGLng.HighLevelApi.Shader import GlShaderManager, GlShaderProgramInterface

# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# 
####################################################################################################

####################################################################################################


####################################################################################################


####################################################################################################

class ConfigPath(object):

    module_path = os.path.dirname(__file__)

    ##############################################

    @staticmethod
    def glsl(file_name):

        return os.path.join(ConfigPath.module_path, 'glslv3', file_name)

####################################################################################################

shader_manager = GlShaderManager()

position_shader_program_interface = GlShaderProgramInterface(uniform_blocks=('viewport',),
                                                             attributes=('position',))


texture_shader_program_interface = GlShaderProgramInterface(uniform_blocks=('viewport',),