Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen resolution change cannot be handled correctly on windows 11 platform #239

Open
cliche9 opened this issue Jun 29, 2023 · 2 comments
Open

Comments

@cliche9
Copy link

cliche9 commented Jun 29, 2023

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:

  1. When I set the screen resolution scale to 100%, the program works fine.
  2. When the program is running, I scale the screen resolution to 125%, the program goes black.
  3. 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?

@wecand0
Copy link

wecand0 commented Jul 19, 2023

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);
}

@Tianyun-Xuan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants