0

我已经从这里为 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。我查了一下,我可以看到freeglut32.vc9.dllfreeglut64.vc9.dllC:\Program Files\Python32\Lib\site-packages\OpenGL\DLLS.

我将上面的代码更改为:

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 调用?我做错了什么?

4

1 回答 1

1

PyOpenGL 默认加载 GLUT dll。要改用 freeglut,请重命名或删除 OpenGL/DLLs 目录中的 glut64.vc9.dll 文件,并确保 Windows DLL 搜索路径中的其他位置不存在此类文件。为我工作。

于 2012-04-28T07:07:08.407 回答