VoxelEngine/Objects/Cube/Cube.py

26 lines
840 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):
GeometryShaderId = -1
2020-07-19 10:41:08 +02:00
2017-08-27 12:51:26 +02:00
def __init__(self):
Object.__init__(self)
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
def initializeShader(self) -> bool:
2017-08-27 12:51:26 +02:00
with open('./Objects/Cube/cube_geometry.glsl', 'r') as f:
geometry_shader_string = f.read()
Cube.GeometryShaderId = glCreateShader(GL_GEOMETRY_SHADER)
glShaderSource(Cube.GeometryShaderId, geometry_shader_string)
glCompileShader(Cube.GeometryShaderId)
if glGetShaderiv(Cube.GeometryShaderId, GL_COMPILE_STATUS) != GL_TRUE:
raise RuntimeError(glGetShaderInfoLog(Cube.GeometryShaderId))
return False
2020-07-19 10:41:08 +02:00
return True