当前位置: 移动技术网 > IT编程>脚本编程>Python > Python安装PyOpenGL

Python安装PyOpenGL

2019年08月18日  | 移动技术网IT编程  | 我要评论

端木新卉微博,孔得红,鸽子情缘谐音

1.目前pyopengl是用python2写的,如果你使用的是python3需要自己修改pyopengl,我这里使用的是python2.7

2.下载pyopenglhttps://pypi.org/project/pyopengl/3.1.0/#modal-close,下载对应系统版本的就可以

  

 

3.运行exe或者setup

4.测试 茶壶

from opengl.gl import *
from opengl.glu import *
from opengl.glut import *

def draw():
    glclear(gl_color_buffer_bit)
    glrotatef(0.5, 0, 1, 0)
    glutwireteapot(0.5)
    glflush()

glutinit()
glutinitdisplaymode(glut_single | glut_rgba)
glutinitwindowsize(400, 400)
glutcreatewindow("test")
glutdisplayfunc(draw)
glutidlefunc(draw)
glutmainloop()

if __name__ == '__main__':
    draw()

5.运行报错(这是因为没有权限导致的

6.将2中下载的pyopengl-3.1.0.zip解压,将\opengl\dlls文件夹复制到python27\lib\site-packages\opengl

7.重新运行测试文件,通过

8.如果你使用python3的环境去运行,会报错,需要你使用2to3或者six模块,将python2的代码转化为python3的

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网