From c1766c95ed57c1deaaf4024f6a53d418420ce297 Mon Sep 17 00:00:00 2001 From: "Adam D. Moss" Date: Sun, 22 Mar 2015 13:49:36 +0000 Subject: [PATCH] OpenGL/GLFW: hide system cursor if imgui is soft-rendering cursor --- examples/opengl3_example/imgui_impl_glfw_gl3.cpp | 11 +++++++++++ examples/opengl_example/imgui_impl_glfw.cpp | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp index cd43effc2..53c13afe4 100644 --- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp +++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp @@ -351,6 +351,17 @@ void ImGui_ImplGlfwGL3_NewFrame() io.MouseWheel = g_MouseWheel; g_MouseWheel = 0.0f; + // Hide/show hardware mouse cursor + if (io.MouseDrawCursor) + { + // imgui draws cursor itself + glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); + } + else + { + glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); + } + // Start the frame ImGui::NewFrame(); } diff --git a/examples/opengl_example/imgui_impl_glfw.cpp b/examples/opengl_example/imgui_impl_glfw.cpp index b7a4844cb..9ea00a4dd 100644 --- a/examples/opengl_example/imgui_impl_glfw.cpp +++ b/examples/opengl_example/imgui_impl_glfw.cpp @@ -255,6 +255,17 @@ void ImGui_ImplGlfw_NewFrame() io.MouseWheel = g_MouseWheel; g_MouseWheel = 0.0f; + // Hide/show hardware mouse cursor + if (io.MouseDrawCursor) + { + // imgui draws cursor itself + glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN); + } + else + { + glfwSetInputMode(g_Window, GLFW_CURSOR, GLFW_CURSOR_NORMAL); + } + // Start the frame ImGui::NewFrame(); }