How to use FreeGLUT glutMouseWheelFunc in PyOpenGL program?

拟墨画扇 提交于 2019-12-12 01:31:43

问题


I have installed PyOpenGL from here for 64-bit Python 3.x and Windows 7. I am able to write and execute a PyOpenGL program that uses glutMouseFunc to listen to mouse button clicks:

from OpenGL.GLUT import *
from OpenGL.GL import *

# Imagine the typical glut init functions here ...
glutMouseFunc( mouse )

Now, I want to read the scroll wheel of the mouse too. I have done this before in C++ using FreeGLUT, which exposes a glutMouseWheelFunc. I checked and I can see freeglut32.vc9.dll and freeglut64.vc9.dll in C:\Program Files\Python32\Lib\site-packages\OpenGL\DLLS.

I changed the above code to:

from OpenGL.GLUT import *
from OpenGL.GLUT.freeglut import *
from OpenGL.GL import *

# Imagine the typical glut init functions here ...
glutMouseFunc( mouse )
glutMouseWheelFunc( mouseWheel )

This fails with this error:

  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

So, how do I use FreeGLUT calls in PyOpenGL? What I am doing wrong?


回答1:


PyOpenGL loads the GLUT dll by default. To use freeglut instead, rename or delete the glut64.vc9.dll file in the OpenGL/DLLs directory and make sure no such file exists elsewhere in the Windows DLL search path. Works for me.



来源:https://stackoverflow.com/questions/10359407/how-to-use-freeglut-glutmousewheelfunc-in-pyopengl-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!