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它的工作。謝謝。 –