【发布时间】:2019-03-14 09:01:55
【问题描述】:
如果我运行这段代码
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GLUT import *
from OpenGL.GLUT.freeglut import *
def on_wheel(wheel, direction, x, y):
print(wheel, direction, x, y)
glutInit()
glutInitWindowSize(100, 100)
glutCreateWindow("glutMouseWheelFunc test")
glutMouseWheelFunc( on_wheel ) # Error here
glutMainLoop()
我收到此错误
Traceback (most recent call last):
File "...", line 28, in <module>
glutMouseWheelFunc( on_wheel )
File ".../OpenGL/GLUT/special.py", line 148, in __call__
self.wrappedOperation( cCallback, *args )
File ".../OpenGL/GLUT/special.py", line 116, in failFunction
typeName, 'glut%sFunc'%(typeName),
OpenGL.error.NullFunctionError: Undefined GLUT callback function MouseWheel,
check for bool(glutMouseWheelFunc) before calling
这是适用于 Windows 的解决方案:
How to use FreeGLUT glutMouseWheelFunc in PyOpenGL program?
但是如何在 Mac 或 linux 上的 pyopengl 中调用 glutMouseWheelFunc()?
或者更好:有便携式解决方案吗?
【问题讨论】:
标签: python glut freeglut pyopengl