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

HiDPI support #5

Open
dcnieho opened this issue Oct 31, 2022 · 5 comments
Open

HiDPI support #5

dcnieho opened this issue Oct 31, 2022 · 5 comments

Comments

@dcnieho
Copy link

dcnieho commented Oct 31, 2022

I'm using a hidpi screen and lavfi-preview is not hidpi aware (I'm using Windows 10). That means everything is super small. In my own imgui+glfw c++ program, I handle this as follows, feel free to copy and adapt in case you'd like to fix this:

// 1. before opening the glfw window
float highDPIscaleFactor = 1.0;
float xscale, yscale;
glfwGetMonitorContentScale(glfwGetPrimaryMonitor(), &xscale, &yscale);
if (xscale > 1 || yscale > 1) {
    highDPIscaleFactor = xscale;
    glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);
}

// 2. after creating imgui context (and before setup Platform/Renderer bindings, but i'm not sure if that's important)
if (highDPIscaleFactor > 1.f) {
    ImGuiStyle& style = ImGui::GetStyle();
    style.ScaleAllSizes(highDPIscaleFactor);
}

This of course does not handle the case of dragging the gui between screens with different dpi, but its something at least.

@dcnieho
Copy link
Author

dcnieho commented Oct 31, 2022

See pthom/imgui_bundle#7 (comment) for python code for handling dragging between differen monitors. Same logic would apply in C++ (but be simpler to implement)

@dcnieho
Copy link
Author

dcnieho commented Oct 31, 2022

And last note: I'm happy to test anything you implement (I have a setup with two screens with different DPI), using the Windows build artefacts.

@richardpl
Copy link
Owner

Added some code to handle this. What about case if window is partially in one monitor and in another monitor?

@dcnieho
Copy link
Author

dcnieho commented Nov 1, 2022 via email

@dcnieho
Copy link
Author

dcnieho commented Nov 1, 2022 via email

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

2 participants