from OpenGL.GL import * import numpy as np from OpenGL.GL.ARB.vertex_array_object import glDeleteVertexArrays from OpenGL.GL.framebufferobjects import glBindRenderbuffer from OpenGL.GLUT import * import OpenGL.GLUT.freeglut from OpenGL.GLU import * from OpenGL.GL import * from ctypes import sizeof, c_float, c_void_p, c_uint from MatrixStuff.Transformations import * class LightingManager: def __init__(self): self.Lights = [] self.renderSteps = [] def addLight(self,l): self.Lights.append(l) def removeLight(self,l): self.Lights.remove(l) class __Renderstep: def render(self, projMatrix, geometryRotMatrix): pass class __Structurestep(__Renderstep): def __init__(self, alternateprogramdict, structure): self.alternateprogramdict = alternateprogramdict self.structure = structure def __eq__(self, other): if type(other) is type(self): return self.alternateprogramdict == other.alternateprogramdict and self.structure == self.structure else: return False def render(self,projMatrix,geometryRotMatrix): self.structure.render(projMatrix,geometryRotMatrix,self.alternateprogramdict) class __Clearstep(__Renderstep): def render(self, projMatrix, geometryRotMatrix): glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) class __ActivateDepthmappingStep(__Renderstep): def __init__(self,light): self.light = light def render(self, projMatrix, geometryRotMatrix): self.light.prepareForDepthMapping() class __DeactivateDepthmappingStep(__Renderstep): def __init__(self, light): self.light = light def render(self, projMatrix, geometryRotMatrix): self.light.finishDepthMapping() def addRenderStep(self,alternateprogramdict,structure): r = self.__Renderstep(alternateprogramdict,structure) self.renderSteps.append(r) def removeRenderStep(self,alternateprogramdict,structure): r = self.__Renderstep(alternateprogramdict,structure) self.renderSteps.remove(r)