Examples Refactor: GLFW: Explicit functions to init GLFW with OpenGL or Vulkan since we cannot read the api hints from glfw.

docking
omar 7 years ago
parent 6e58a95a01
commit 09d8943967

@ -111,7 +111,7 @@ void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback); glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
} }
bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks) static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
{ {
g_Window = window; g_Window = window;
@ -163,16 +163,18 @@ bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports) if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports)
ImGui_ImplGlfw_InitPlatformInterface(); ImGui_ImplGlfw_InitPlatformInterface();
g_ClientApi = GlfwClientApi_OpenGL; g_ClientApi = client_api;
return true; return true;
} }
bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks)
{
return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_OpenGL);
}
bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks) bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks)
{ {
if (!ImGui_ImplGlfw_Init(window, install_callbacks)) return ImGui_ImplGlfw_Init(window, install_callbacks, GlfwClientApi_Vulkan);
return false;
g_ClientApi = GlfwClientApi_Vulkan;
return true;
} }
void ImGui_ImplGlfw_Shutdown() void ImGui_ImplGlfw_Shutdown()

@ -12,7 +12,7 @@
struct GLFWwindow; struct GLFWwindow;
IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks); IMGUI_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks);
IMGUI_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); IMGUI_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks);
IMGUI_API void ImGui_ImplGlfw_Shutdown(); IMGUI_API void ImGui_ImplGlfw_Shutdown();
IMGUI_API void ImGui_ImplGlfw_NewFrame(); IMGUI_API void ImGui_ImplGlfw_NewFrame();

@ -31,7 +31,7 @@ int main(int, char**)
ImGui::CreateContext(); ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io; ImGuiIO& io = ImGui::GetIO(); (void)io;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
ImGui_ImplGlfw_Init(window, true); ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL2_Init(); ImGui_ImplOpenGL2_Init();
// Setup style // Setup style

@ -40,7 +40,7 @@ int main(int, char**)
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls //io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
ImGui_ImplGlfw_Init(window, true); ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init(); ImGui_ImplOpenGL3_Init();
// Setup style // Setup style

Loading…
Cancel
Save