我有以下代码:
import pyglet
from OpenGL.GL import *
from OpenGL.GLU import *
class Window(pyglet.window.Window):
def __init__(self,width,height):
super(Window,self).__init__(width,height)
glClearDepth(1.0)
glDepthFunc(GL_LESS)
glEnable(GL_DEPTH_TEST)
glShadeModel(GL_SMOOTH)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
def on_draw(self):
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
#I know this is deprecated
glTranslatef(0.0,0.0,-5.0)
glColor3f(1.0,1.0,1.0)
glBegin(GL_TRIANGLES)
glVertex3f(0.0,0.0,0.0)
glVertex3f(0.0,1.0,0.0)
glVertex3f(1.0,0.0,0.0)
glEnd()
def on_resize(self,width,height):
glViewport(0,0,width,height)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45.0,float(width)/float(height),0.1,100.0)
glMatrixMode(GL_MODELVIEW)
当我使用 pyglet 的 opengl 绑定时,它按预期工作。但是,当我使用 pyopengl 时,我只看到一团糟。