1

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?

genpfault
  • 51,148
  • 11
  • 85
  • 139
mentics
  • 6,852
  • 5
  • 39
  • 93
  • Although the answers diverting away from GLUT are correct and useful, the answer to the literal question is use keyboardMouseCallback. The mousewheel event doesn't work, but the keyboardMouseCallback does handle wheel events as well, so it does work in GLUT. – mentics Jan 31 '11 at 21:55

3 Answers3

2

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

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Oops! "GLFW applications can only open one window." I need multiple. Looks like I need to use... WX? Can't find anything in wx or wxcore about opengl... – mentics Jan 31 '11 at 21:37
  • @taotree: Either WX or GTK, probably. You want a GLCanvas in WX; it doesn't seem to exist in the main package, I guess due to lack of demand, but does exist in wxcore. – C. A. McCann Jan 31 '11 at 21:48
  • I don't know enough WX yet for what it means that it's in wxcore but not in wx. Does that mean I can still use it simple, or does it have to have to be implemented in wx to support it first? – mentics Feb 01 '11 at 17:33
1

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.

ephemient
  • 198,619
  • 38
  • 280
  • 391
1

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.

C. A. McCann
  • 76,893
  • 19
  • 209
  • 302
  • With GLFW one maintains a custom main loop, too. – datenwolf Jan 31 '11 at 20:05
  • @datenwolf: Oh, really? Hunh! For some reason I thought it used callbacks as well, but obviously I've never used it myself, so my mistake. Always ended up using SDL or a full UI toolkit like gtk/wx for various other reasons. Anyway, thanks for pointing that out! – C. A. McCann Jan 31 '11 at 21:35
  • For completeness, it appears GLFW can do it either way: custom loop or register callbacks. – mentics Jan 31 '11 at 21:39