Listing 2. Same Program Using Togl
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.Tk import *
def display(togl):
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glMaterialfv(GL_FRONT, GL_AMBIENT,
[0.1745, 0.0, 0.1, 0.0])
glMaterialfv(GL_FRONT, GL_DIFFUSE,
[0.1, 0.0, 0.6, 0.0])
glMaterialfv(GL_FRONT, GL_SPECULAR,
[0.7, 0.6, 0.8, 0.0])
glMaterialf(GL_FRONT, GL_SHININESS, 80)
glutSolidTeapot(1.5)
glFlush()
togl = Opengl(width = 250, height = 250, double = 1)
togl.redraw = display
togl.pack(side = 'top', expand = 1, fill = 'both')
togl.basic_lighting()
togl.set_background(0, 0, 0)
togl.mainloop()
Copyright © 1994 - 2019 Linux Journal. All rights reserved.