VoxelEngine/Objects/Cube/Cube.py

23 lines
809 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 *
import numpy as np
2020-07-19 10:41:08 +02:00
2017-08-27 12:51:26 +02:00
class Cube(Object):
def __init__(self):
2020-07-25 15:03:05 +02:00
super(Cube, self).__init__()
2020-07-19 10:41:08 +02:00
if (Cube.GeometryShaderId == -1):
2017-08-27 12:51:26 +02:00
self.initializeShader()
2020-07-19 10:41:08 +02:00
2020-07-25 15:03:05 +02:00
@classmethod
def initializeShader(cls) -> bool:
2017-08-27 12:51:26 +02:00
with open('./Objects/Cube/cube_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(Cube.GeometryShaderId, geometry_shader_string)
glCompileShader(Cube.GeometryShaderId)
if glGetShaderiv(Cube.GeometryShaderId, GL_COMPILE_STATUS) != GL_TRUE:
raise RuntimeError(glGetShaderInfoLog(Cube.GeometryShaderId))
2020-07-25 15:03:05 +02:00
return True