Hello Guest

How to get mouse DWheel in GLFW

  • 3 Replies
  • 6738 Views
How to get mouse DWheel in GLFW
« on: December 18, 2014, 01:54:14 »
I'm still trying to get used to the new input system in GLFW. I know how to get key input by using glfwGetKey(), but there ins't a "glfwGetScroll()" or something, and I don't like using window callback adapters because they are slow. How can I get the mouse wheel movement without the adapter?

*

Offline Zeroni

  • *
  • 10
  • Notice me sempai.
Re: How to get mouse DWheel in GLFW
« Reply #1 on: December 18, 2014, 02:16:41 »
I do not know where you got the notion that the window callback adapters are slow, because it is not true (I only get a few microseconds delay). I use a window class with all the all callback adapters, and I haven't noticed any notable input lagg, it may be just your machine. I do not know a way of get the scroll without the callback adapters in LWJGL 3.0.

I would message user: spasi
He may know a way to get the scroll outside of the Graphics Library Framework.
- Zeroni

*

Offline SHC

  • **
  • 94
    • GoHarsha.com
Re: How to get mouse DWheel in GLFW
« Reply #2 on: December 18, 2014, 05:40:05 »
See the glfwSetScrollCallback() function. In Java, you can do the following.

Code: [Select]
GLFW.glfwSetScrollCallback(window, scrollCallback = GLFWScrollCallback((win, dx, dy) ->
{
    // Store dx and dy here (both are double values)
    Mouse.dx = dx;
    Mouse.dy = dy;
});
Just make sure that you call [icode]scrollCallback.release()[/icode] before destroying the window. Hope this helps.

*

Offline quew8

  • *****
  • 569
  • Because Square Eyes Look More Real
Re: How to get mouse DWheel in GLFW
« Reply #3 on: December 18, 2014, 10:41:37 »
GLFW isn't built around the concept of a game loop. It can be used for any application, so it really makes no sense to have a getScroll() function - what would it return? But as @SHC says, it is trivial code to replicate the LWJGL2 functionality, and as @Zeroni says, it is not at all slow. Even if it was I don't know what you would be comparing it to.