在 Haskell 的 GLUT 窗口中,人们如何对鼠标滚轮事件做出反应?
我正在使用 OpenGL 包,并且还使用 GLUT 包。尽管 GLUT 包似乎有鼠标滚轮回调,但它似乎不起作用(文档说仅 freeglut)。
那么...在一个 GLUT 创建的窗口中,如何访问鼠标滚轮事件?
I'm using the OpenGL package, and was using the GLUT package as well. Although the GLUT package appears to have a mouse wheel callback, it doesn't appear to work (doc says freeglut only).
So... inside an GLUT created window, how does one get access to the mouse wheel events?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
OpenGL 不创建窗口。本质上,它只是一堆绘制东西的函数。事件处理它完全超出了OpenGL的范围。 GLUT 不是 OpenGL 的核心部分。这是一个相当古老的库,其目的是使编写简单的 OpenGL 教程变得容易。而已。
您应该使用更高级的 GLFW,而不是 GLUT,它也存在出色的 Haskell 绑定:http://hackage。 haskell.org/package/GLFW
OpenGL does not create windows. In the essence it's just a bunch of functions to draw things. Event processing it completely out of the scope of OpenGL. GLUT is not a core part of OpenGL. It's a rather old library with the purpose of making writing simple OpenGL tutorials easy. Nothing more.
Instead of GLUT you should use the far superior GLFW, for which also excellent Haskell bindings exist: http://hackage.haskell.org/package/GLFW
只是为了添加另一个选项......
当我厌倦了过剩时,我切换到 Gtk2Hs。 wiki 上有几个简单的示例演示 GtkGLext。
Just to add another option…
When I got fed up with GLUT, I switched to Gtk2Hs. There's a couple simple samples on the wiki demonstrating GtkGLext.
我还建议避免过剩。无论如何,它是相当有限的。
如果您更喜欢处理自己的主事件循环而不是使用回调,另一种选择是使用 SDL 。是的,它是为游戏设计的,但它可以为您提供 GL 上下文,并且对于大多数不需要标准 UI 小部件的交互式 OpenGL 应用程序来说效果很好。它为您提供键盘/鼠标事件、毫秒计时器和一些非常基本的窗口管理。
有点无意义的事后编辑:我在评论中得知 GLFW 还允许运行您自己的事件循环。再次查看之后,我绝对同意 GLFW 是处理大多数不需要标准 UI 小部件的事情的方法。
I also advise avoiding GLUT. It's pretty limited anyway.
Another option, if you prefer to process your own main event loop rather than using callbacks, is using SDL. Yes, it's intended for games, but it can give you a GL context and works well enough for most interactive OpenGL applications that don't need standard UI widgets. It gives you keyboard/mouse events, millisecond timers, and some very basic window management.
KINDA POINTLESS POST-HOC EDIT: I have been informed in a comment that GLFW also allows running your own event loop. After looking at it again, I definitely concur that GLFW is the way to go for most things that don't need standard UI widgets.