Repository: ocornut/imgui (language: rust)

Issue:
GLFW backend checks for vulkan support by GLFW version. Why?
**Version/Branch of Dear ImGui:**

Version: 1.89.6 WIP
Branch: docking

**Back-end/Renderer/Compiler/OS**

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: aarch64 gcc
Operating System: Nintendo Switch

**My Issue/Question:**

I do not have vulkan, and the GLFW impl in the docking branch simply does a version check to determine if it should go forward with vulkan calls. Why isn't this detected in a different way or even done through a define? Anyway, I can get my application to compile and for and run on switch by replacing the version check with: ``#define GLFW_HAS_VULKAN false // 3.2+ glfwCreateWindowSurface``, but it would be ideal to not have to edit the source code for the sake of upgradability.

I would include a verifiable example but I doubt you want to set up the whole homebrew devkit and compiler stuff. It takes a while. But I figure it's fine for a simpler question like this.



Discussion / hints:
If this reads sorta like a question and sorta like a request, it's because I'm well aware that there's possibly some part I don't understand. But if I do have a full understanding of this its more of a request.
> Why isn't this detected in a different way or even done through a define? 

Well we do a version check because that function was added in that GLFW version. What else would you want to check on?

I suppose some GLFW-port for your homebrew devkit doesn't have those function.
Coincidentally it is exactly the same problem as #6468 but for a different platform.
We could tweak that specific #ifdef to ignore Vulkan path on Switch devkit for now.

Does your SDK define a Switch-specific define?

Not really... ``SWITCH`` is common in community code but it's not defined by the devkit, rather by makefiles or cmakelists within projects. Maybe an imgui specific define is the way to go?
That pull request does not resolve the issue on switch - although the issues are similar, switch will need a separate define. I'd submit a PR for switch, but I don't know what to call the define, as there isn't anything provided by the SDK. I'd imagine one would have to be created specifically for ImGui, and for that I'd need to know what naming scheme to go with.
You would need to discuss this with homebrew switch SDK maintainers perhaps. There must be some simili standards in place?
Oh, I was more suggesting a define be expected within ImGui, but not necessarily be defined by the SDK. Though I found that the makefile that pretty much every homebrew switch application copies defines ``__SWITCH__``, and so does the one existing cmake toolchain. I suppose that would be a good thing to check against.

Shall I submit a pull request?

Yes.

Fix patch:
diff --git a/backends/imgui_impl_glfw.cpp b/backends/imgui_impl_glfw.cpp
index cf4fd40a4c77..87ea528b1fe4 100644
--- a/backends/imgui_impl_glfw.cpp
+++ b/backends/imgui_impl_glfw.cpp
@@ -102,7 +102,7 @@
 #define GLFW_HAS_WINDOW_HOVERED         (GLFW_VERSION_COMBINED >= 3300) // 3.3+ GLFW_HOVERED
 #define GLFW_HAS_WINDOW_ALPHA           (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwSetWindowOpacity
 #define GLFW_HAS_PER_MONITOR_DPI        (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetMonitorContentScale
-#ifdef __EMSCRIPTEN__                   // no Vulkan support in Emscripten's GLFW
+#if defined(__EMSCRIPTEN__) || defined(__SWITCH__)                      // no Vulkan support in GLFW for Emscripten or homebrew Nintendo Switch
 #define GLFW_HAS_VULKAN                 (0)
 #else
 #define GLFW_HAS_VULKAN                 (GLFW_VERSION_COMBINED >= 3200) // 3.2+ glfwCreateWindowSurface


Test patch: