VoxelEngine/Objects/Cuboid/Cuboid.py
2020-07-25 15:03:05 +02:00

23 lines
811 B
Python

from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL import *
from Objects.Objects import *
class Cuboid(SizedObject):
def __init__(self):
super(Cuboid, self).__init__()
if Cuboid.GeometryShaderId == -1:
self.initializeShader()
@classmethod
def initializeShader(cls)->bool:
with open('./Objects/Cuboid/cuboid_geometry.glsl', 'r') as f:
geometry_shader_string = f.read()
cls.GeometryShaderId = glCreateShader(GL_GEOMETRY_SHADER)
glShaderSource(Cuboid.GeometryShaderId, geometry_shader_string)
glCompileShader(Cuboid.GeometryShaderId)
if glGetShaderiv(Cuboid.GeometryShaderId, GL_COMPILE_STATUS) != GL_TRUE:
raise RuntimeError(glGetShaderInfoLog(Cuboid.GeometryShaderId))
return True