BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / python / #8421同步于 2015/8/31
Python机器人发帖

求解一个关于PyOpenGL的问题

dsfour
2015/8/31镜像同步0 回复
按教程的代码如下: --------------------------------------------------- # -*-coding:gbk -*- # file:OpenGl_8.31.py __author__ = 'ljs' from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.GLU import * import sys class OpenGLWindow: def __init__(self,width=640,height=480,title="PyOpenGL"): glutInit(sys.argv) glutInitDisplayMode(GLUT_RGBA|GLUT_DOUBLE|GLUT_DEPTH) glutInitWindowSize(width,height) self.window=glutCreateWindow(title) glutDisplayFunc(self.Draw) self.InitGL(width,height) def Draw(self): glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT) glLoadIdentity() glutSwapBuffers() def InitGL(self,width,height): glClearColor(0.0,0.0,0.0,0.0) glClearDepth(1,0) glDepthFunc(GL_LESS) glEnable(GL_DEPTH_TEST) glShadeModel(GL_SMOOTH) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(45.0,float(width)/float(width),0.1,100.0) glMatrixMode(GL_MODELVIEW) def MainLoop(self): glutMainLoop() window=OpenGLWindow() window.MainLoop() 分隔线-------------------------------------------------- 然后提示错误: C:\Python27\python.exe C:/Python27/OpenGL_1.py Traceback (most recent call last): File "C:/Python27/OpenGL_1.py", line 32, in <module> window=OpenGLWindow() File "C:/Python27/OpenGL_1.py", line 10, in __init__ glutInit(sys.argv) File "C:\Python27\lib\site-packages\OpenGL\GLUT\special.py", line 333, in glutInit _base_glutInit( ctypes.byref(count), holder ) File "C:\Python27\lib\site-packages\OpenGL\platform\baseplatform.py", line 407, in __call__ self.__name__, self.__name__, OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling 这是为什么呢?glutInit()函数为什么跪了,难道需要自己写?
订阅后,新回复会通过你的通知中心匿名送达。
0 条回复
暂无回复 · 你可以订阅本帖等待新回复。