VoxelEngine/Objects/Cuboid/Cuboid.py

24 lines
811 B
Python
Raw Normal View History

2017-08-27 12:51:26 +02:00
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL import *
from Objects.Objects import *
2020-07-25 15:03:05 +02:00
class Cuboid(SizedObject):
2017-08-27 12:51:26 +02:00
def __init__(self):
2020-07-25 15:03:05 +02:00
super(Cuboid, self).__init__()
if Cuboid.GeometryShaderId == -1:
2017-08-27 12:51:26 +02:00
self.initializeShader()
2020-07-25 15:03:05 +02:00
@classmethod
def initializeShader(cls)->bool:
2017-08-27 12:51:26 +02:00
with open('./Objects/Cuboid/cuboid_geometry.glsl', 'r') as f:
geometry_shader_string = f.read()
2020-07-25 15:03:05 +02:00
cls.GeometryShaderId = glCreateShader(GL_GEOMETRY_SHADER)
2017-08-27 12:51:26 +02:00
glShaderSource(Cuboid.GeometryShaderId, geometry_shader_string)
glCompileShader(Cuboid.GeometryShaderId)
if glGetShaderiv(Cuboid.GeometryShaderId, GL_COMPILE_STATUS) != GL_TRUE:
raise RuntimeError(glGetShaderInfoLog(Cuboid.GeometryShaderId))
2020-07-25 15:03:05 +02:00
return True