【问题标题】:How to use FreeGLUT glutMouseWheelFunc in PyOpenGL program?如何在 PyOpenGL 程序中使用 FreeGLUT glutMouseWheelFunc?
【发布时间】:2012-04-28 00:16:01
【问题描述】:

我已经为 64 位 Python 3.x 和 Windows 7 安装了来自 herePyOpenGL。我能够编写和执行使用 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.dllfreeglut64.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 调用?我做错了什么?

【问题讨论】:

    标签: python pyopengl freeglut


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2019-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-11
      • 2013-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多