我是靠谱客的博主 等待月光,这篇文章主要介绍pyopengl 安装与测试,现在分享给大家,希望可以做个参考。

笔者通过PyCharm安装pyopengl,然后运行测试程序会出现错误 :OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit, check for bool(glutInit) before calling

https://stackoverflow.com/questions/26700719/pyopengl-glutinit-nullfunctionerror

正确的安装方法为下载.whl文件,然后通过pip安装,whl下载网址为:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl

 

请下载跟你python版本一样的whl文件,笔者Python版本为3.5

  • PyOpenGL‑3.1.4‑cp35‑cp35m‑win32.whl
  • PyOpenGL‑3.1.4‑cp35‑cp35m‑win_amd64.whl
  • PyOpenGL_accelerate‑3.1.4‑cp35‑cp35m‑win32.whl
  • PyOpenGL_accelerate‑3.1.4‑cp35‑cp35m‑win_amd64.whl

记得先卸载PyCharm 安装的pyopengl,通过

pip uninstall PyOpenGL

pip uninstall PyOpenGL-accelerate

如果你的电脑是64位,则使用如下命令安装:

pip install PyOpenGL‑3.1.4‑cp35‑cp35m‑win_amd64.whl

pip install PyOpenGL_accelerate‑3.1.4‑cp35‑cp35m‑win_amd64.whl

如果你的电脑是32位,则使用如下命令安装:

pip install PyOpenGL‑3.1.4‑cp35‑cp35m‑win32.whl

pip install PyOpenGL_accelerate‑3.1.4‑cp35‑cp35m‑win32.whl

 

测试代码:

如下是显示茶壶的测试代码:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * def drawFunc(): glClear(GL_COLOR_BUFFER_BIT) # glRotatef(1, 0, 1, 0) glutWireTeapot(0.5) glFlush() glutInit() glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA) glutInitWindowSize(400, 400) glutCreateWindow("First") glutDisplayFunc(drawFunc) # glutIdleFunc(drawFunc) glutMainLoop()

运行结果如下所示:

 

 

 

 

最后

以上就是等待月光最近收集整理的关于pyopengl 安装与测试的全部内容,更多相关pyopengl内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(107)

评论列表共有 0 条评论

立即
投稿
返回
顶部