我想了解游戏编程的基础知识,并且已经为此安装了pygame
和pyopengl
。PyOpenGL TypeError:'NoneType'对象不可调用
mycode的:
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。
你的pyopengl安装似乎有问题:'_base_glutInit'在'OpenGL/GLUT/special.py'中是'None'。 – 2012-04-17 09:54:08
@FerdinandBeyer:我使用'easy_install'安装了它,所以我建议你从源代码进行干净安装。 – RanRag 2012-04-17 09:57:39
@FerdinandBeyer:你的建议在那里工作是有问题的安装。我从源头上安装它,它工作得很好。 – RanRag 2012-04-17 10:03:36