Mouse Wheel not in use

youmumyon wrote on Saturday, November 08, 2014:

I am trying to do a basic thing with the mouse wheel: set scrollY with the value passed to a callback function, and use it to scale an object.
However, when I am not scrolling, the function is not called and then it keeps the last value, and because of this, scrollY is never set to 0 and then the object is always scaling.
How can I set scrollY to 0 when I am not using the mouse wheel?

dougbinks wrote on Saturday, November 08, 2014:

The glfw3 input function for scrolling, glfwSetScrollCallback(), passes deltas rather than absolute values.

So to use this to modify a global value g_Scale, you could do the following:

float g_Scale           = 1.0f;
float g_MouseWheelScale = 0.1f;

void ScrollCallback( GLFWwindow* window, double x, double y )
{
    g_Scale  += g_MouseWheelScale  * (float)y;
}

// somewhere in your main function call:
glfwSetScrollCallback( pWindow, ScrollCallback );