# Path: e3d/fse_management/FullScreenEffectClass.py
# class FullScreenEffect(object):
#     def __init__(self, filePath, ID, shadersDefaultPath=''):
#         self.ID = ID
#         self.textures2d = {}
#         self.texturesCube = {}
#         self.shaders = {}
#         self.techniques = {}
#         self.custom = {}
#         self.activeTechnique = ''
#         self.builtTechniques = []
#         self.targets = {}
#         self.textureType = None
#         self.description = ''
#         filePath = path.abspath(filePath)
#         localdir = path.dirname(filePath)
# 
#         elements = self.__loadFromFile(filePath)
#         for l in elements:
#             if l.type == typesEnum.technique:
#                 passN = 0
#                 for pp in l.passes:
#                     pp.name = passN
#                     passN += 1
#                 self.techniques[l.name] = l
#             elif l.type == typesEnum.shader:
#                 if l.source == '':
#                     lfile = l.members['file']
#                     if path.exists(path.abspath(lfile)):
#                         rawPath = lfile
#                     elif path.exists(path.join(localdir, lfile)):
#                         rawPath = path.join(localdir, lfile)
#                     else:
#                         if shadersDefaultPath != '':
#                             rawPath = path.join(shadersDefaultPath, path.basename(lfile))
#                         else:
#                             rawPath = ''
# 
#                     if not path.exists(rawPath):
#                         raise RuntimeError('shader file \'{}\' for \'{}\' effect not found'.format(l.members['file'], ID))
#                     else:
#                         with open(rawPath) as sourceFile:
#                             source = sourceFile.read()
#                         l.source = source
#                 self.shaders[l.name] = l.source
#             elif l.type == typesEnum.texture2d:
#                 self.textures2d[l.name] = l
#             elif l.type == typesEnum.textureCube:
#                 self.texturesCube[l.name] = l
#             elif l.type == typesEnum.target:
#                 self.targets[l.name] = l
#             elif l.type == typesEnum.effect:
#                 self.description = l.members.get('description', '')
#                 self.textureType = l.members['texturetype'].lower()
#             else:
#                 if l.type not in self.custom.keys():
#                     self.custom[l.type] = {}
#                 self.custom[l.type][l.name] = l
# 
#         excludes = ['_raw', '_scene', '_depth', '_stencil']
#         for t in self.techniques.values():
#             for p in t.passes:
#                 for out in p.members['out']:
#                     if out not in self.targets.keys() and out not in excludes:
#                         raise UnboundLocalError(': required target \'{}\' '
#                                                 'for technique \'{}\' not defined.'.format(out, t.name))
# 
#     def __repr__(self):
#         return '{}:\nTechniques {}, Texture2d {}, TextureCube {}, Shaders {}, Targets {}'.format(
#             self.ID,
#             len(self.techniques),
#             len(self.textures2d),
#             len(self.texturesCube),
#             len(self.shaders),
#             len(self.targets)
#         )
# 
#     def __loadFromFile(self, filePath):
#         with open(filePath) as ffile:
#             lines = ffile.readlines()
#             nonComentLines = [l for l in lines if not l.startswith('//')]
#             cleanedLines = []
#             for l in nonComentLines:
#                 commentStart = l.find('//')
#                 if commentStart > -1:
#                     l = l[:commentStart].rstrip()
#                 cleanedLines.append(l)
#             source = str('\n').join(cleanedLines)
# 
#         source = source.strip()
#         return _extractElements(source)
# 
#     def getActiveTechnique(self):
#         """
# 
#         @rtype : Element
#         """
#         return self.techniques.get(self.activeTechnique)
# 
# Path: e3d/backends/RenderTargetBase.py
# class attachmentTypeEnum(object):
#     color = 'color'
#     depth = 'depth'
#     stencil = 'stencil'
# 
# class renderTextureTypeEnum(object):
#     cube = 'cube'
#     t2D = '2d'
# 
# Path: e3d/backends/base_backend.py
# class CompilationError(RuntimeError):
#     pass
# 
# class BaseBackend(object):
#     __metaclass__ = ABCMeta
# 
#     def __init__(self):
#         self._shaders = None
#         self._textures = None
#         self._poliCount = 0
#         self._culling = False
# 
#     def renderMeshes(self, drawingData):
#         pass
# 
#     def resize(self, size):
#         pass
# 
#     def drawAll(self, drawingData):
#         pass
# 
#     def drawSkybox(self, sky):
#         pass
# 
#     def switchMultiSample(self, value):
#         pass
# 
#     def terminate(self):
#         pass
# 
#     def getShadersManager(self):
#         pass
# 
#     @staticmethod
#     def getRenderTarget():
#         pass
# 
#     def _getPoliCount(self):
#         return self._poliCount
# 
#     poligonsDrawnThisUpdate = property(_getPoliCount)
# 
#     @staticmethod
#     def _getMaxColorAttachments():
#         pass
# 
#     def setContextState(self):
#         pass
# 
#     @property
#     def culling(self):
#         return self._culling
# 
#     @culling.setter
#     def culling(self, value):
#         pass
# 
#     @staticmethod
#     def create2DTexture(ID, mipmapsNumber, pix, w, h, repeat):
#         pass
# 
#     def update2DTexture(self, ID, data, fromTuple, toTuple):
#         pass
# 
#     def getBackBufferContent(self, w, h, destBuffer):
#         pass


from .FullScreenEffectClass import FullScreenEffect
from ..backends.RenderTargetBase import attachmentTypeEnum, renderTextureTypeEnum
from ..backends.base_backend import CompilationError, BaseBackend
from glaze.GL import glDetachShader




class FSEManager(object):
    class states(object):
        disable = 0

# Path: e3d/fse_management/FullScreenEffectClass.py
# class FullScreenEffect(object):
#     def __init__(self, filePath, ID, shadersDefaultPath=''):
#         self.ID = ID
#         self.textures2d = {}
#         self.texturesCube = {}
#         self.shaders = {}
#         self.techniques = {}
#         self.custom = {}
#         self.activeTechnique = ''
#         self.builtTechniques = []
#         self.targets = {}
#         self.textureType = None
#         self.description = ''
#         filePath = path.abspath(filePath)
#         localdir = path.dirname(filePath)
# 
#         elements = self.__loadFromFile(filePath)
#         for l in elements:
#             if l.type == typesEnum.technique:
#                 passN = 0
#                 for pp in l.passes:
#                     pp.name = passN
#                     passN += 1
#                 self.techniques[l.name] = l
#             elif l.type == typesEnum.shader:
#                 if l.source == '':
#                     lfile = l.members['file']
#                     if path.exists(path.abspath(lfile)):
#                         rawPath = lfile
#                     elif path.exists(path.join(localdir, lfile)):
#                         rawPath = path.join(localdir, lfile)
#                     else:
#                         if shadersDefaultPath != '':
#                             rawPath = path.join(shadersDefaultPath, path.basename(lfile))
#                         else:
#                             rawPath = ''
# 
#                     if not path.exists(rawPath):
#                         raise RuntimeError('shader file \'{}\' for \'{}\' effect not found'.format(l.members['file'], ID))
#                     else:
#                         with open(rawPath) as sourceFile:
#                             source = sourceFile.read()
#                         l.source = source
#                 self.shaders[l.name] = l.source
#             elif l.type == typesEnum.texture2d:
#                 self.textures2d[l.name] = l
#             elif l.type == typesEnum.textureCube:
#                 self.texturesCube[l.name] = l
#             elif l.type == typesEnum.target:
#                 self.targets[l.name] = l
#             elif l.type == typesEnum.effect:
#                 self.description = l.members.get('description', '')
#                 self.textureType = l.members['texturetype'].lower()
#             else:
#                 if l.type not in self.custom.keys():
#                     self.custom[l.type] = {}
#                 self.custom[l.type][l.name] = l
# 
#         excludes = ['_raw', '_scene', '_depth', '_stencil']
#         for t in self.techniques.values():
#             for p in t.passes:
#                 for out in p.members['out']:
#                     if out not in self.targets.keys() and out not in excludes:
#                         raise UnboundLocalError(': required target \'{}\' '
#                                                 'for technique \'{}\' not defined.'.format(out, t.name))
# 
#     def __repr__(self):
#         return '{}:\nTechniques {}, Texture2d {}, TextureCube {}, Shaders {}, Targets {}'.format(
#             self.ID,
#             len(self.techniques),
#             len(self.textures2d),
#             len(self.texturesCube),
#             len(self.shaders),
#             len(self.targets)
#         )
# 
#     def __loadFromFile(self, filePath):
#         with open(filePath) as ffile:
#             lines = ffile.readlines()
#             nonComentLines = [l for l in lines if not l.startswith('//')]
#             cleanedLines = []
#             for l in nonComentLines:
#                 commentStart = l.find('//')
#                 if commentStart > -1:
#                     l = l[:commentStart].rstrip()
#                 cleanedLines.append(l)
#             source = str('\n').join(cleanedLines)
# 
#         source = source.strip()
#         return _extractElements(source)
# 
#     def getActiveTechnique(self):
#         """
# 
#         @rtype : Element
#         """
#         return self.techniques.get(self.activeTechnique)
# 
# Path: e3d/backends/RenderTargetBase.py
# class attachmentTypeEnum(object):
#     color = 'color'
#     depth = 'depth'
#     stencil = 'stencil'
# 
# class renderTextureTypeEnum(object):
#     cube = 'cube'
#     t2D = '2d'
# 
# Path: e3d/backends/base_backend.py
# class CompilationError(RuntimeError):
#     pass
# 
# class BaseBackend(object):
#     __metaclass__ = ABCMeta
# 
#     def __init__(self):
#         self._shaders = None
#         self._textures = None
#         self._poliCount = 0
#         self._culling = False
# 
#     def renderMeshes(self, drawingData):
#         pass
# 
#     def resize(self, size):
#         pass
# 
#     def drawAll(self, drawingData):
#         pass
# 
#     def drawSkybox(self, sky):
#         pass
# 
#     def switchMultiSample(self, value):
#         pass
# 
#     def terminate(self):
#         pass
# 
#     def getShadersManager(self):
#         pass
# 
#     @staticmethod
#     def getRenderTarget():
#         pass
# 
#     def _getPoliCount(self):
#         return self._poliCount
# 
#     poligonsDrawnThisUpdate = property(_getPoliCount)
# 
#     @staticmethod
#     def _getMaxColorAttachments():
#         pass
# 
#     def setContextState(self):
#         pass
# 
#     @property
#     def culling(self):
#         return self._culling
# 
#     @culling.setter
#     def culling(self, value):
#         pass
# 
#     @staticmethod
#     def create2DTexture(ID, mipmapsNumber, pix, w, h, repeat):
#         pass
# 
#     def update2DTexture(self, ID, data, fromTuple, toTuple):
#         pass
# 
#     def getBackBufferContent(self, w, h, destBuffer):
#         pass


# Path: e3d/fse_management/FSEManagerClass.py
from .FullScreenEffectClass import FullScreenEffect
from ..backends.RenderTargetBase import attachmentTypeEnum, renderTextureTypeEnum
from ..backends.base_backend import CompilationError, BaseBackend
from glaze.GL import glDetachShader





class FSEManager(object):
    class states(object):
        disable = 0

        enabled = 1