from OpenGL.GL import * class Material: def __init__(self, diffuse=[0.8, 0.8, 0.8, 1], ambient=[0.2, 0.2, 0.2, 1], specular=[0, 0, 0, 1], shininess=0): self.ambient = ambient self.diffuse = diffuse self.specular = specular self.shininess = shininess self.emission = [0, 0, 0, 1] def apply(self): glEnable(GL_LIGHTING) glMaterialfv(GL_FRONT, GL_AMBIENT, self.ambient) glMaterialfv(GL_FRONT, GL_DIFFUSE, self.diffuse) glMaterialfv(GL_FRONT, GL_SPECULAR, self.specular) glMaterialf(GL_FRONT, GL_SHININESS, self.shininess) glMaterialfv(GL_FRONT, GL_EMISSION, self.emission) def disable(self): glDisable(GL_LIGHTING)