今天尝试了下:python和OpenGL的结合,遇到问题如下:
IDE:Python2.6+PyOpenGL-3.0.2.win32-py2.6+Windows7
代码如下:
1 import sys
2 import OpenGL
3
4 from OpenGL.GL import *
5 from OpenGL.GLU import *
6 from OpenGL.GLUT import *
7
8 def draw():
9 glClear(GL_COLOR_BUFFER_BIT)
10 glutWireTeapot(0.5)
11 glFlush()
12
13 glutInit(sys.argv)
14 glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
15 glutInitWindowSize(250, 250)
16 glutInitWindowPosition(100, 100)
17 glutCreateWindow("Python OGL Program")
18 glutDisplayFunc(draw)
19 glutMainLoop()
20
21 draw()
当我运行的时候出现如下提示:
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'objectisnot callable
于是,baidu+google之:
最后的解决办法如下:
I solved it by using an unoffical pyopengl package.
参考文章:http://choorucode.com/2012/04/27/pyopengl-installation-notes/
非官方PyOpenGL下载路径:http://www.lfd.uci.edu/~gohlke/pythonlibs/
找到
PyOpenGL,下载合适的版本即可!