如何解决PyOpenGL :: OpenGL.error.NullFunctionError:尝试调用未定义的函数 glutInit,在调用之前检查 bool(glutInit)
我非常关注这个easy guide,以便我迈出进入 PyOpenGL 的第一步。
-
我安装了
period_to
,一切正常。 -
我通过测试代码测试了安装:
导入OpenGL.GL 导入 OpenGL.GLUT 导入OpenGL.GLU print("Imports successfully!") # 如果你看到这个打印到控制台,那么安装成功
一切顺利
我现在运行这个脚本:
pip install PyOpenGL PyOpenGL_accelerate
我收到的错误是 from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
w,h= 500,500
def square():
glBegin(GL_QUADS)
glVertex2f(100,100)
glVertex2f(200,200)
glVertex2f(100,200)
glEnd()
def iterate():
glViewport(0,500,500)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(0.0,0.0,1.0)
glMatrixMode (GL_MODELVIEW)
glLoadIdentity()
def showScreen():
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glLoadIdentity()
iterate()
glColor3f(1.0,3.0)
square()
glutSwapBuffers()
glutInit()
glutInitDisplayMode(GLUT_RGBA)
glutInitWindowSize(500,500)
glutInitWindowPosition(0,0)
wind = glutCreateWindow("OpenGL Coding Practice")
glutDisplayFunc(showScreen)
glutIdleFunc(showScreen)
glutMainLoop()
所以我在网上阅读了一些指南,他们指出从 here 下载轮子。所以我继续下载OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit,check for bool(glutInit) before calling
和PyOpenGL_accelerate‑3.1.5‑cp38‑cp38‑win_amd64.whl
,因为我正在运行PyOpenGL‑3.1.5‑cp38‑cp38‑win_amd64.whl
-
Python 3.8
返回pip install .\PyOpenGL_accelerate-3.1.5-cp39-cp39-win_amd64.whl
-
PyOpenGL-accelerate is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.
返回pip install .\PyOpenGL_accelerate-3.1.5-cp38-cp38-win_amd64.whl
一个如此简单的指南怎么会导致我如此痛苦的结果?
如何检查是否安装了 PyOpenGL-accelerate is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.
。也许这是我遗漏的唯一一步?
解决方法
包中缺少 freeglut DLL。
卸载“PyOpenGL”:
pip uninstall pyopengl
从 Unofficial Windows Binaries for Python Extension Packages 下载包轮(“PyOpenGL‑3.1.5‑cp39‑cp39‑win_amd64.whl”)并安装:
pip install PyOpenGL‑3.1.5‑cp39‑cp39‑win_amd64.whl
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。