本文介绍了PyOpenGL :: OpenGL.error.NullFunctionError:尝试调用未定义的函数 glutInit,在调用之前检查 bool(glutInit)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在遵循这个非常简单指南 为了使我迈出 PyOpenGL 的第一步.

I'm following this very easy guide in order to make my first steps into PyOpenGL.

  1. 我安装了 pip install PyOpenGL PyOpenGL_accelerate ,一切都很好.

我通过测试代码测试了安装:

I tested the installation through the test code:

导入OpenGL.GL导入 OpenGL.GLUT导入OpenGL.GLUprint("导入成功!") # 如果你看到这个打印到控制台,那么安装成功

import OpenGL.GLimport OpenGL.GLUTimport OpenGL.GLUprint("Imports successful!") # If you see this printed to the console then installation was successful

一切顺利

我现在运行这个脚本:

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 call

所以我在网上阅读了一些指南,他们指出从下载轮子这里.所以我继续下载 PyOpenGL_accelerate‑3.1.5‑cp38‑cp38‑win_amd64.whlPyOpenGL‑3.1.5‑cp38‑cp38‑win_amd64.whl 因为我正在运行 Python 3.8

So i read a few guides online and they point to download the wheel from here. So I go ahead and I download PyOpenGL_accelerate‑3.1.5‑cp38‑cp38‑win_amd64.whl and PyOpenGL‑3.1.5‑cp38‑cp38‑win_amd64.whl because I'm running Python 3.8

  1. pip install .\PyOpenGL_accelerate-3.1.5-cp39-cp39-win_amd64.whl 返回 PyOpenGL-accelerate 已经安装了与提供的轮子相同的版本.使用 --force-reinstall 强制安装轮子.
  2. pip install .\PyOpenGL_accelerate-3.1.5-cp38-cp38-win_amd64.whl 返回 PyOpenGL-accelerate 已经安装了与提供的轮子相同的版本.使用 --force-reinstall 强制安装轮子.
  1. pip install .\PyOpenGL_accelerate-3.1.5-cp39-cp39-win_amd64.whl returns 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 returns PyOpenGL-accelerate is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.

一个如此简单的指南怎么会导致我如此痛苦的结果?

How can a so simple guide lead me to a so painful result?

如何检查是否安装了 Visual C++ 14.0 构建工具.也许这是我遗漏的唯一一步?

How can I check if Visual C++ 14.0 build tools is installed. Maybe that is the only step I'm missing?

推荐答案

freeglut DLL 从包中丢失.

The freeglut DLL is missing from the package.

卸载PyOpenGL":

Unistall "PyOpenGL":

pip uninstall pyopengl

Python 扩展包的非官方 Windows 二进制文件 并安装它:

pip install PyOpenGL‑3.1.5‑cp39‑cp39‑win_amd64.whl

这篇关于PyOpenGL :: OpenGL.error.NullFunctionError:尝试调用未定义的函数 glutInit,在调用之前检查 bool(glutInit)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 20:27