Examples: GLFW*: Renamed GLFW callbacks exposed in .h to not include GL2/GL3/Vulkan in their name.
diff --git a/examples/opengl2_example/imgui_impl_glfw_gl2.cpp b/examples/opengl2_example/imgui_impl_glfw_gl2.cpp
index d4a4357..42075e4 100644
--- a/examples/opengl2_example/imgui_impl_glfw_gl2.cpp
+++ b/examples/opengl2_example/imgui_impl_glfw_gl2.cpp
@@ -19,6 +19,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
+// 2018-02-20: Inputs: Renamed GLFW callbacks exposed in .h to not include GL2 in their name.
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplGlfwGL2_RenderDrawData() in the .h file so you can call it yourself.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
@@ -144,20 +145,20 @@
glfwSetClipboardString((GLFWwindow*)user_data, text);
}
-void ImGui_ImplGlfwGL2_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
{
if (action == GLFW_PRESS && button >= 0 && button < 3)
g_MouseJustPressed[button] = true;
}
-void ImGui_ImplGlfwGL2_ScrollCallback(GLFWwindow*, double xoffset, double yoffset)
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double xoffset, double yoffset)
{
ImGuiIO& io = ImGui::GetIO();
io.MouseWheelH += (float)xoffset;
io.MouseWheel += (float)yoffset;
}
-void ImGui_ImplGlfwGL2_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+void ImGui_ImplGlfw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
{
ImGuiIO& io = ImGui::GetIO();
if (action == GLFW_PRESS)
@@ -172,7 +173,7 @@
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
}
-void ImGui_ImplGlfwGL2_CharCallback(GLFWwindow*, unsigned int c)
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
{
ImGuiIO& io = ImGui::GetIO();
if (c > 0 && c < 0x10000)
@@ -216,6 +217,14 @@
}
}
+static void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
+{
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+}
+
bool ImGui_ImplGlfwGL2_Init(GLFWwindow* window, bool install_callbacks)
{
g_Window = window;
@@ -251,12 +260,7 @@
#endif
if (install_callbacks)
- {
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfwGL2_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfwGL2_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlfwGL2_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfwGL2_CharCallback);
- }
+ ImGui_ImplGlfw_InstallCallbacks(window);
return true;
}
diff --git a/examples/opengl2_example/imgui_impl_glfw_gl2.h b/examples/opengl2_example/imgui_impl_glfw_gl2.h
index 268b0e4..4e0f393 100644
--- a/examples/opengl2_example/imgui_impl_glfw_gl2.h
+++ b/examples/opengl2_example/imgui_impl_glfw_gl2.h
@@ -26,7 +26,7 @@
// GLFW callbacks (registered by default to GLFW if you enable 'install_callbacks' during initialization)
// Provided here if you want to chain callbacks yourself. You may also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfwGL2_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfwGL2_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlfwGL2_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfwGL2_CharCallback(GLFWwindow* window, unsigned int c);
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
index 2409768..16f8964 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.cpp
@@ -13,6 +13,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
+// 2018-02-20: Inputs: Renamed GLFW callbacks exposed in .h to not include GL3 in their name.
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplGlfwGL3_RenderDrawData() in the .h file so you can call it yourself.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
@@ -168,20 +169,20 @@
glfwSetClipboardString((GLFWwindow*)user_data, text);
}
-void ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
{
if (action == GLFW_PRESS && button >= 0 && button < 3)
g_MouseJustPressed[button] = true;
}
-void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow*, double xoffset, double yoffset)
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double xoffset, double yoffset)
{
ImGuiIO& io = ImGui::GetIO();
io.MouseWheelH += (float)xoffset;
io.MouseWheel += (float)yoffset;
}
-void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+void ImGui_ImplGlfw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
{
ImGuiIO& io = ImGui::GetIO();
if (action == GLFW_PRESS)
@@ -196,7 +197,7 @@
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
}
-void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow*, unsigned int c)
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
{
ImGuiIO& io = ImGui::GetIO();
if (c > 0 && c < 0x10000)
@@ -331,6 +332,14 @@
}
}
+static void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
+{
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+}
+
bool ImGui_ImplGlfwGL3_Init(GLFWwindow* window, bool install_callbacks)
{
g_Window = window;
@@ -366,12 +375,7 @@
#endif
if (install_callbacks)
- {
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfwGL3_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfwGL3_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlfwGL3_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfwGL3_CharCallback);
- }
+ ImGui_ImplGlfw_InstallCallbacks(window);
return true;
}
diff --git a/examples/opengl3_example/imgui_impl_glfw_gl3.h b/examples/opengl3_example/imgui_impl_glfw_gl3.h
index 0e039d8..71ea412 100644
--- a/examples/opengl3_example/imgui_impl_glfw_gl3.h
+++ b/examples/opengl3_example/imgui_impl_glfw_gl3.h
@@ -25,7 +25,7 @@
// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
// Provided here if you want to chain callbacks.
// You can also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfwGL3_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfwGL3_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlfwGL3_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfwGL3_CharCallback(GLFWwindow* window, unsigned int c);
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
diff --git a/examples/vulkan_example/imgui_impl_glfw_vulkan.cpp b/examples/vulkan_example/imgui_impl_glfw_vulkan.cpp
index 31f22e8..3b3a1f0 100644
--- a/examples/vulkan_example/imgui_impl_glfw_vulkan.cpp
+++ b/examples/vulkan_example/imgui_impl_glfw_vulkan.cpp
@@ -10,6 +10,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
+// 2018-02-20: Inputs: Renamed GLFW callbacks exposed in .h to not include Vulkan in their name.
// 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback, ImGui_ImplGlfwVulkan_Render() calls ImGui_ImplGlfwVulkan_RenderDrawData() itself.
// 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves.
// 2018-02-06: Inputs: Added mapping for ImGuiKey_Space.
@@ -340,20 +341,20 @@
glfwSetClipboardString((GLFWwindow*)user_data, text);
}
-void ImGui_ImplGlfwVulkan_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
+void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
{
if (action == GLFW_PRESS && button >= 0 && button < 3)
g_MouseJustPressed[button] = true;
}
-void ImGui_ImplGlfwVulkan_ScrollCallback(GLFWwindow*, double xoffset, double yoffset)
+void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double xoffset, double yoffset)
{
ImGuiIO& io = ImGui::GetIO();
io.MouseWheelH += (float)xoffset;
io.MouseWheel += (float)yoffset;
}
-void ImGui_ImplGlfwVulkan_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
+void ImGui_ImplGlfw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
{
ImGuiIO& io = ImGui::GetIO();
if (action == GLFW_PRESS)
@@ -368,7 +369,7 @@
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
}
-void ImGui_ImplGlfwVulkan_CharCallback(GLFWwindow*, unsigned int c)
+void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
{
ImGuiIO& io = ImGui::GetIO();
if (c > 0 && c < 0x10000)
@@ -746,6 +747,14 @@
if (g_Pipeline) { vkDestroyPipeline(g_Device, g_Pipeline, g_Allocator); g_Pipeline = VK_NULL_HANDLE; }
}
+static void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
+{
+ glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
+ glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
+ glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
+ glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
+}
+
bool ImGui_ImplGlfwVulkan_Init(GLFWwindow* window, bool install_callbacks, ImGui_ImplGlfwVulkan_Init_Data *init_data)
{
g_Allocator = init_data->allocator;
@@ -789,12 +798,7 @@
#endif
if (install_callbacks)
- {
- glfwSetMouseButtonCallback(window, ImGui_ImplGlfwVulkan_MouseButtonCallback);
- glfwSetScrollCallback(window, ImGui_ImplGlfwVulkan_ScrollCallback);
- glfwSetKeyCallback(window, ImGui_ImplGlfwVulkan_KeyCallback);
- glfwSetCharCallback(window, ImGui_ImplGlfwVulkan_CharCallback);
- }
+ ImGui_ImplGlfw_InstallCallbacks(window);
ImGui_ImplGlfwVulkan_CreateDeviceObjects();
diff --git a/examples/vulkan_example/imgui_impl_glfw_vulkan.h b/examples/vulkan_example/imgui_impl_glfw_vulkan.h
index 54918d3..5d2b63c 100644
--- a/examples/vulkan_example/imgui_impl_glfw_vulkan.h
+++ b/examples/vulkan_example/imgui_impl_glfw_vulkan.h
@@ -39,8 +39,8 @@
// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
// Provided here if you want to chain callbacks.
// You can also handle inputs yourself and use those as a reference.
-IMGUI_API void ImGui_ImplGlfwVulkan_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
-IMGUI_API void ImGui_ImplGlfwVulkan_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
-IMGUI_API void ImGui_ImplGlfwVulkan_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
-IMGUI_API void ImGui_ImplGlfwVulkan_CharCallback(GLFWwindow* window, unsigned int c);
+IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
+IMGUI_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
+IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);