python - PyOpenGL 类型错误 : 'NoneType' object is not callable

标签 python pyopengl

我正在努力学习游戏编程的基础知识,为此我已经安装了 pygamepyopengl

我的代码:

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/

相关文章:

python - 为什么 glDrawElements 调用失败?

python - 使用 ctypes.c_void_p 作为 glTexImage2D 的输入?

python - OpenGL 三角形旋转序列

Python 神经网络反向传播

python - Django 脆皮表单 - 在 home.html 中创建表单并收到错误

python - lxml Python包将版权符号更改为HTML实体

opengl - 如何避免现代 GPU 上三角形之间出现黑线?

python - 设置基于值计数和分组依据的数据框列值

python - 读取 Pandas Dataframe 中的列值

python - 我想两次使用 object a class 但它没有发生