我努力学习游戏编程的基础知识,我已经安装pygame,并pyopengl为.
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()
Run Code Online (Sandbox Code Playgroud)
当我在命令提示符下运行上面的代码时使用
python test.py
Run Code Online (Sandbox Code Playgroud)
我收到以下错误.
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
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我会收到这个错误.我glutinit是以错误的方式打电话的?
我使用的是Python 2.7.2.
我使用setup.py安装(具有管理员权限)在Python 3.2上安装了PyOpenGL-3.0.2b2,它出现了与OP相同的错误.安装脚本没有复制DLLS文件夹,因此您必须自己复制整个文件夹\ PyOpenGL-3.0.2b2\OpenGL\DLLS.
这对我有用,希望它可以帮助其他人.
小智 5
在linux os中你应该 在ubuntu 12.04中安装freeglut3:
sudo apt-get install freeglut3
Run Code Online (Sandbox Code Playgroud)
问题出在我的PyOpenGL安装上。早些时候我使用安装它easy_install。
因此,正如 @Ferdinand 所说,您的 pyopengl 安装似乎有问题。
我使用它进行了全新安装python setup.py install并且成功了。
| 归档时间: |
|
| 查看次数: |
9144 次 |
| 最近记录: |