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

zgui: support high DPI screens (retina) #258

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

zgui: support high DPI screens (retina) #258

tanis2000 opened this issue Mar 24, 2023 · 7 comments

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
Collaborator

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
Collaborator

@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
Collaborator

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
Collaborator

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

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