mentics
mentics

Reputation: 6999

How does one react to mouse wheel events in an GLUT window in Haskell?

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?

Upvotes: 1

Views: 1297

Answers (3)

C. A. McCann
C. A. McCann

Reputation: 77384

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.

Upvotes: 1

ephemient
ephemient

Reputation: 204768

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.

Upvotes: 1

datenwolf
datenwolf

Reputation: 162164

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

Upvotes: 2

Related Questions