Skip to content

Mix of low and high DPI displays #1

New issue

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

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

Already on GitHub? # to your account

Open
tanis2000 opened this issue Mar 24, 2023 · 8 comments
Open

Mix of low and high DPI displays #1

tanis2000 opened this issue Mar 24, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@tanis2000
Copy link

It would be nice if you could add support for high DPI screens like Retina displays in zgui.

What I have seen some people do is to grab the DisplaySize and FramebufferScale vectors from ImGui's ImDrawData and just multiply them together to get the actual viewport size to apply. I believe everything else can be left intact.

@michal-z
Copy link

High DPI is already supported. The correct way is to use:
style.scaleAllSizes(scale_factor);
Take a look at the gui_test_wgpu sample application.

Also see: https://github.com/ocornut/imgui/blob/master/docs/FAQ.md#q-how-should-i-handle-dpi-in-my-application

@michal-z
Copy link

@tanis2000 Can we close this issue?

@tanis2000
Copy link
Author

I have not yet had the chance to check that out. I am working on this project on and off. I will try to have a look at it today and update the ticket.

@tanis2000
Copy link
Author

Ok I just tested this both in my game and with the gui_test_wgpu sample and it doesn't really look correct. Or at least this is not what I would expect :)

Here is the sample project running first on the high dpi screen (a Retina MBP monitor) and then on a low dpi 1080p monitor. I just run the project starting on the hdpi screen and then dragged it to the ldpi screen and this is the result:

zig-gamedev__gui_test__wgpu__hdpi_screen

zig-gamedev__gui_test__wgpu__ldpi_screen

This doesn't really look like the expected behavior.

I noticed in the logs that the hdpi reports a window size of 3024x1832 and the ldpi a window size of 1512x916
And, in fact, the scale_factor of the hdpi is being set to 2 for the hdpi screen.

I tried to move the code that calculates the scale_factor before the zgui.backend.newFrame so that it gets the right scale not just during the initialization but it has a weird side effect where the title bar of the window seems to take over the whole screen. I haven't checked yet how the 'scaleAllSizes' function works under the hood.

@michal-z
Copy link

michal-z commented Mar 29, 2023

Opening a window on a HDPI screen and dragging it to LDPI window is not supported currently. I need to think about this case. Thanks for checking it.

@tanis2000
Copy link
Author

Fair enough. Please feel free to close this issue if you do not need as a reference for that use-case :)

@michal-z
Copy link

Let's leave this open I would like to support this case.

@hazeycode hazeycode transferred this issue from zig-gamedev/zig-gamedev Nov 5, 2024
@hazeycode hazeycode changed the title zgui: support high DPI screens (retina) Support high DPI screens (retina) Nov 5, 2024
@hazeycode hazeycode changed the title Support high DPI screens (retina) Mix of low and high DPI displays Jan 2, 2025
@hazeycode hazeycode added the bug Something isn't working label Jan 2, 2025
@hazeycode
Copy link
Member

hazeycode commented May 5, 2025

Now that we're on a more recent version of imgui (with multi-monitor fixes) since this was reported and I think this could potentially be fixed by #42.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants