【发布时间】:2012-04-28 00:16:01
【问题描述】:
我已经为 64 位 Python 3.x 和 Windows 7 安装了来自 here 的 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 调用?我做错了什么?
【问题讨论】: