0
我想运行一个简单的OpenGL代码:如何在Windows上的Anaconda上安装GLUT?
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
window = 0 # glut window number
width, height = 500, 400 # window size
def draw(): # ondraw is called all the time
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) # clear the screen
glLoadIdentity() # reset position
# ToDo draw rectangle
glutSwapBuffers() # important for double buffering
# initialization
glutInit() # initialize glut
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
glutInitWindowSize(width, height) # set window size
glutInitWindowPosition(0, 0) # set window position
window = glutCreateWindow("noobtuts.com") # create window with title
glutDisplayFunc(draw) # set draw function callback
glutIdleFunc(draw) # draw all the time
glutMainLoop()
但每次我试图执行它,我得到这个错误:
OpenGL.error.NullFunctionError: Attempt to call an undefined function glutInit,
check for bool(glutInit) before calling
根据this question的问题是glut.dll
和glut32.dll
不是PyOpenGL
包的一部分。所以我下载了dll文件并将它们复制到C:/Windows/SysWOW64
,并将该文件夹添加到PATH
,但错误仍然存在。在上面的同一个问题引用中,一个用户也建议将dll文件应用到Python OpenGL DLL
文件夹。
我在哪里可以在我的Ananconda安装中找到这个文件夹?或者我应该在哪里复制dll文件来完成这项工作?由于
当我在我的Windows安装的OpenGL系统,我遵循[** this **](https://codeyarns.com/2012/04/27/pyopengl-installation-notes-for-windows/)说明并从[下载]中下载二进制文件(* .whl *)[ **这里**](http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl) – Rabbid76
@ Rabbid76它的工作。谢谢。 –