我已经从here为64位Python 3.x和Windows 7安装了 PyOpenGL 。我能够编写和执行使用 glutMouseFunc的PyOpenGL程序收听鼠标按钮点击:
from OpenGL.GLUT import *
from OpenGL.GL import *
# Imagine the typical glut init functions here ...
glutMouseFunc( mouse )
现在,我想阅读鼠标的滚轮。我之前在C ++中使用FreeGLUT完成了这项工作,它暴露了 glutMouseWheelFunc 。我检查过,我可以在C:\Program Files\Python32\Lib\site-packages\OpenGL\DLLS
中看到 freeglut32.vc9.dll 和 freeglut64.vc9.dll 。
我将上面的代码更改为:
from OpenGL.GLUT import *
from OpenGL.GLUT.freeglut import *
from OpenGL.GL import *
# Imagine the typical glut init functions here ...
glutMouseFunc( mouse )
glutMouseWheelFunc( mouseWheel )
此失败并出现此错误:
File "c:\Program Files\Python32\lib\site-packages\OpenGL\GLUT\special.py", line 139, in __call__
self.wrappedOperation( cCallback, *args )
File "c:\Program Files\Python32\lib\site-packages\OpenGL\GLUT\special.py", line 107, in failFunction
typeName, 'glut%sFunc'%(typeName),
OpenGL.error.NullFunctionError: Undefined GLUT callback function MouseWheel, check for bool(glutMouseWheelFunc) before calling
那么,如何在PyOpenGL中使用FreeGLUT调用?我做错了什么?
答案 0 :(得分:0)
PyOpenGL默认加载GLUT dll。要使用freeglut,请重命名或删除OpenGL / DLLs目录中的glut64.vc9.dll文件,并确保Windows DLL搜索路径中的其他位置不存在此类文件。适合我。