首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >PyOpenGL ::OpenGL.error.NullFunctionError:尝试调用未定义的函数glutInit,在调用之前检查bool(glutInit)

PyOpenGL ::OpenGL.error.NullFunctionError:尝试调用未定义的函数glutInit,在调用之前检查bool(glutInit)
EN

Stack Overflow用户
提问于 2021-01-13 10:06:46
回答 1查看 7K关注 0票数 6

我遵循这个易导,以便进入PyOpenGL的第一步。

  1. 我安装了pip install PyOpenGL PyOpenGL_accelerate,很好。
  2. 我通过测试代码测试了安装: 导入OpenGL.GL导入OpenGL.GLUT导入OpenGL.GLU打印(“导入成功”)#如果您看到这个输出到控制台,那么安装就成功了

都很好

我现在运行这个脚本:

代码语言:javascript
运行
复制
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, 100)
    glVertex2f(200, 200)
    glVertex2f(100, 200)
    glEnd()

def iterate():
    glViewport(0, 0, 500, 500)
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    glOrtho(0.0, 500, 0.0, 500, 0.0, 1.0)
    glMatrixMode (GL_MODELVIEW)
    glLoadIdentity()

def showScreen():
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    glLoadIdentity()
    iterate()
    glColor3f(1.0, 0.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()

我收到的错误是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.whlPyOpenGL‑3.1.5‑cp38‑cp38‑win_amd64.whl,因为我运行的是Python 3.8

  1. 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.
  2. 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.

这么简单的指导怎么能把我引向如此痛苦的结果呢?

如何检查是否安装了Visual C++ 14.0 build tools。也许这是我唯一错过的一步?

EN

Stack Overflow用户

回答已采纳

发布于 2021-01-13 10:15:59

包中缺少freeglut DLL。

统一"PyOpenGL":

代码语言:javascript
运行
复制
pip uninstall pyopengl

用于Python扩展包的非官方Windows二进制文件下载包轮(例如:“PyOpenGL-3.1.6cp311-cp311-winamd64.whl”)并安装它:

代码语言:javascript
运行
复制
pip install PyOpenGL‑3.1.6‑cp311‑cp311‑win_amd64.whl
票数 11
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65699670

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档