How to get mouse DWheel in GLFW

Started by Andrew_3ds, December 18, 2014, 01:54:14

Previous topic - Next topic

Andrew_3ds

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?

Zeroni

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

SHC

See the glfwSetScrollCallback() function. In Java, you can do the following.

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 scrollCallback.release() before destroying the window. Hope this helps.

quew8

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.