Fix text distortion on mobile devices/browsers with `glow` backend (#6893)

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

Did not test on platforms other than my phone, but I can't imagine it
causing problems. AFAIK if highp isn't supported then `precision highp
float;` needs to still not cause the program to fail to link/compile or
anything; it should just silently use some other precision.

* Fixes https://github.com/emilk/egui/issues/4268 for me but I only
tested it on a native Android app and I don't know whether backends
other than glow are affected.
* [x] I have followed the instructions in the PR template (but the
change is trivial so I'm just doing it from the master branch)

Before:

![image](https://github.com/user-attachments/assets/9f449749-5a48-4e9c-aef0-7a8ac3912eb6)

After:

![image](https://github.com/user-attachments/assets/544e5977-13e0-411a-bccf-b15a15289e28)
This commit is contained in:
Alexander Nadeau 2025-04-30 08:12:08 -04:00 committed by GitHub
parent f3611e3e5a
commit 6c922f72a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -1,5 +1,11 @@
#ifdef GL_ES
precision mediump float;
// To avoid weird distortion issues when rendering text etc, we want highp if possible.
// But apparently some devices don't support it, so we have to check first.
#if defined(GL_FRAGMENT_PRECISION_HIGH) && GL_FRAGMENT_PRECISION_HIGH == 1
precision highp float;
#else
precision mediump float;
#endif
#endif
uniform sampler2D u_sampler;

View File

@ -9,7 +9,13 @@
#endif
#ifdef GL_ES
precision mediump float;
// To avoid weird distortion issues when rendering text etc, we want highp if possible.
// But apparently some devices don't support it, so we have to check first.
#if defined(GL_FRAGMENT_PRECISION_HIGH) && GL_FRAGMENT_PRECISION_HIGH == 1
precision highp float;
#else
precision mediump float;
#endif
#endif
uniform vec2 u_screen_size;