Example apps: accumulate mouse wheel to accodomate for slow framerate.

This commit is contained in:
ocornut 2014-11-30 17:41:08 +00:00
parent 0e6f288a2f
commit 0730ec7577
3 changed files with 3 additions and 4 deletions

View File

@ -317,7 +317,7 @@ LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
io.MouseDown[1] = false; io.MouseDown[1] = false;
return true; return true;
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
io.MouseWheel = GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f; io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
return true; return true;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
// Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.) // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)

View File

@ -153,7 +153,7 @@ LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
io.MouseDown[1] = false; io.MouseDown[1] = false;
return true; return true;
case WM_MOUSEWHEEL: case WM_MOUSEWHEEL:
io.MouseWheel = GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f; io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
return true; return true;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
// Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.) // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)

View File

@ -114,7 +114,7 @@ static void glfw_mouse_button_callback(GLFWwindow* window, int button, int actio
static void glfw_scroll_callback(GLFWwindow* window, double xoffset, double yoffset) static void glfw_scroll_callback(GLFWwindow* window, double xoffset, double yoffset)
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
io.MouseWheel = (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines. io.MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
} }
static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) static void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
@ -258,7 +258,6 @@ int main(int argc, char** argv)
{ {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
mousePressed[0] = mousePressed[1] = false; mousePressed[0] = mousePressed[1] = false;
io.MouseWheel = 0;
glfwPollEvents(); glfwPollEvents();
UpdateImGui(); UpdateImGui();