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

Fix DPI scaling in examples #570

Merged
merged 1 commit into from Dec 20, 2021
Merged

Fix DPI scaling in examples #570

merged 1 commit into from Dec 20, 2021

Conversation

dbr
Copy link
Contributor

@dbr dbr commented Nov 20, 2021

Extending from #504,

  1. Using HiDpiMode::Default is indeed a good default
  2. As noted in comments (and in comment on the linked PR), imgui-winit-support + winit handles most of the scaling for us
  3. However imgui's default bitmap font then looks a bit naff (most likely why Rounded was used in first place), so I've changed the default font to Roboto as that was already in the repo
  4. I've enabled oversampling on this font as it helps with the default rasterizer
  5. The font rendering still then doesn't look too great due to imgui-glium-renderer's lack of proper compositing, so I've kept the "multiplier" value (but nudged down a little as I think it looks "better")

Overall I think this makes the DPI scale handling about as close to correct as it can be - so for example if I force the DPI scale to 1, and 6, it just looks like a 6x scale:

scaling example

overlay

Point 5 does kind of hints we should either add some easy sRGB mode into glium-renderer, or switch the examples to using imgui-glow-renderer (which already does the correct thing by default)

- winit handles the DPI factor scaling
- Remove "rounded" mode which is only sensible with default bitmap screen on a low pixel density screen
- As such change default font to the already-in-repo Roboto
- Adds env-var to examples to force scaling factor for debug purposes
@dbr
Copy link
Contributor Author

dbr commented Nov 21, 2021

Only thing I've not really tested is what happens when you drag a window between different DPI screens - winit emits an event for these, but I'm not sure if there is additional work needed

@sanbox-irl
Copy link
Member

yeah i'd say this is totally fine. Nice work

@sanbox-irl sanbox-irl merged commit 22436d9 into imgui-rs:main Dec 20, 2021
@dbr dbr deleted the dpiscale branch January 11, 2023 23:19
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

Successfully merging this pull request may close these issues.

None yet

2 participants