为 Python 3.5.2 使用 freeglut 设置 PyOpenGL

Setting up PyOpenGL with freeglut for Python 3.5.2

我正在尝试将我的机器设置为使用 PyOpenGL 和 freeglut。我有 Python 版本 3.5.2 和 Windows 8.

的 64 位副本

我已经使用 pip 下载了 PyOpenGL,然后下载了 freeglut 并将 include\lib\ 文件夹放在了 C:\Program Files\Common Files\MSVC\freeglut。我还在环境变量 linking 中放置了一个 link 到 64 位 freeglut.dll 文件到 C:\Work\freeglut.dll

因为我不知道任何 OpenGL,所以我只是尝试 运行 此页面中的代码以查看我的设置是否正常运行 http://www.de-brauwer.be/wiki/wikka.php?wakka=PyOpenGLSierpinski。当 运行 我收到错误消息

Traceback (most recent call last):
  File "sier_tri.py", line 35, in <module>
    glutInit()
  File "C:\Users\Dylan\AppData\Local\Programs\Python\Python35-32\lib\site-packag
es\OpenGL\GLUT\special.py", line 333, in glutInit
    _base_glutInit( ctypes.byref(count), holder )
  File "C:\Users\Dylan\AppData\Local\Programs\Python\Python35-32\lib\site-packag
es\OpenGL\platform\baseplatform.py", line 407, in __call__
    self.__name__, self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit,
check for bool(glutInit) before calling

有谁知道是什么导致 this/how 修复它?

glut32.dll 放在 py 文件旁边。

勾选这个

我通过切换到 32 位 freeglut.dll 文件解决了这个问题。我认为 32 位与 64 位取决于您的操作系统,但它实际上取决于您拥有哪种 Python,因为我有 32 位 Python 我需要 32 位 dll。