VoxelEngine/Lights/LightingManager.py

60 lines
2.1 KiB
Python
Raw Normal View History

2017-08-27 12:51:26 +02:00
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
2017-08-27 12:51:26 +02:00
def __eq__(self, other):
if type(other) is type(self):
return self.alternateprogramdict == other.alternateprogramdict and self.structure == self.structure
2017-08-27 12:51:26 +02:00
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)
2017-08-27 12:51:26 +02:00
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)
2017-08-27 12:51:26 +02:00
self.renderSteps.append(r)
def removeRenderStep(self,alternateprogramdict,structure):
r = self.__Renderstep(alternateprogramdict,structure)
2017-08-27 12:51:26 +02:00
self.renderSteps.remove(r)