imgui-node-editor
imgui-node-editor copied to clipboard
Screen resolution change cannot be handled correctly on windows 11 platform
Thanks for creating such an amazing node-editor framework, it's really great!
Here is my issue which has been raised in imgui
issues.
Here is the link to this issue: https://github.com/ocornut/imgui/issues/6556#issue-1778994593
Version/Branch of Dear ImGui:
Version: 1.89.6 Branch: docking
Back-end/Renderer/Compiler/OS/Dependencies
Back-ends: GLFW Renderer: OpenGL Compiler: MSVC 2022 Operating System: Windows 11 Dependencies: imgui-node-editor and GLFW&OpenGL related(glm, glad, etc.)
My Issue/Question:
- When I set the screen resolution scale to 100%, the program works fine.
- When the program is running, I scale the screen resolution to 125%, the program goes black.
- When my screen resolution is set to 125%, the program goes wired. The mouse cannot operate correctly, as if a single mouse position occupies multiple pixels, making it impossible to perform proper positioning and selection operations.
It seems like the screen's dpi change cannot be handled correctly. I don't know how to address this problem.
I already checked my code, I have a same code structure like the blueprint
example, but the problem still exists, any ideas about this?
Hi, I solved this issue with adding determing scale factor. Add such method in application/platform_glfw.cpp
float getDisplayScaleFactor() {
float xscale = 1.f;
float yscale = 1.f;
auto monitor = glfwGetPrimaryMonitor();
if (monitor)
glfwGetMonitorContentScale(monitor, &xscale, &yscale);
return 0.5f * (xscale + yscale);
}
And change UpdatePixelDencity() to :
void PlatformGLFW::UpdatePixelDensity() {
float xscale, yscale;
glfwGetWindowContentScale(m_Window, &xscale, &yscale);
float scale = xscale > yscale ? xscale : yscale;
#if PLATFORM(WINDOWS)
float windowScale = scale;
float framebufferScale = scale;
#else
float windowScale = getDisplayScaleFactor();//1.0f;
float framebufferScale = scale;
#endif
SetWindowScale(windowScale);// this is how windows is scaled, not window content
SetFramebufferScale(framebufferScale);
}
float getDisplayScaleFactor() { float xscale = 1.f; float yscale = 1.f; auto monitor = glfwGetPrimaryMonitor(); if (monitor) glfwGetMonitorContentScale(monitor, &xscale, &yscale); return 0.5f * (xscale + yscale); }
Thanks this works for me