我正在努力学习游戏编程的基础知识,为此我已经安装了 pygame
和 pyopengl
。
我的代码:
import sys
import OpenGL
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
def draw():
glClear(GL_COLOR_BUFFER_BIT)
glutWireTeapot(0.5)
glFlush()
glutInit(sys.argv)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutInitWindowSize(250, 250)
glutInitWindowPosition(100, 100)
glutCreateWindow("Python OGL Program")
glutDisplayFunc(draw)
glutMainLoop()
draw()
当我在命令提示符下运行上述代码时,使用
python test.py
我收到以下错误。
Traceback (most recent call last):
File "test.py", line 13, in <module>
glutInit(sys.argv)
File "C:\Python27\lib\site-packages\pyopengl-3.0.2a5-py2.7.egg\OpenGL\GLUT\special.py", line 324, in glutInit
_base_glutInit( ctypes.byref(count), holder )
TypeError: 'NoneType' object is not callable
我不明白为什么会出现此错误。我是否以错误的方式调用 glutinit
?
我使用的是 Python 2.7.2。
最佳答案
我在 Windows 7 64 位上使用 Python 2.7.3,遇到了一个问题,导致与 Noob 相同的症状。
但是上面的 PyOpenGL 重新安装解决方案对我没有帮助。
我尝试了一个远射 - 安装 freeglut - 它有所帮助!
我使用了来自 here 的 Windows MSVC 2.8.0 二进制包并相应地将 32 位和 64 位 DLL 删除到我的 32 位 (c:\Windows\SysWOW64) 和 64 位 (C:\Windows\System32) 目录中。
关于python - PyOpenGL 类型错误 : 'NoneType' object is not callable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10188595/