Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

EP_HIGH_DPI=false issue on OSX Catalina #2594

Open
ArnisLielturks opened this issue Feb 27, 2020 · 11 comments
Open

EP_HIGH_DPI=false issue on OSX Catalina #2594

ArnisLielturks opened this issue Feb 27, 2020 · 11 comments

Comments

@ArnisLielturks
Copy link
Contributor

When setting EP_HIGH_DPI to false, only 1/4 of the screen is used.
It was working just fine with the High Sierra OSX version.

image

@eugeneko
Copy link
Contributor

I have EP_HIGH_DPI=false-related issues in Web, too.
Does anybody know what exactly EP_HIGH_DPI is supposed to do?

@weitjong
Copy link
Contributor

@ArnisLielturks Don't have latest macOS to test but if you search the "Catalina" and "SDL" then you will find Urho3D is not alone. Before Catalina, Urho3D user could choose between high DPI or not. It used to be "off" by default but now it is "on" by default after we "believe" that UI scaling works correctly with High DPI now. So, the build option is there for users to fallback should they find the scaling does not work as expected for their apps. But, I just read from someone claiming Apple has changed something on Catalina.

The EP_HIGH_DPI in Urho3D translates to SDL_WINDOW_ALLOW_HIGHDPI in SDL 2. At the time we introduced this, I remember the flag only takes effect for Apple platforms. However, a quick check today shows that other platforms seem to start to support that flag as well: Emscripten/Web and Linux/Wayland. Having said that, that combinations are not tested at all in the past.

@ArnisLielturks
Copy link
Contributor Author

@weitjong btw what is considered correct UI scaling in high DPI mode? UI scale is 2x when on high DPI mode or the UI is scale is 1x and on high DPI everything should appear smaller?

@weitjong
Copy link
Contributor

Should be 2x as I recall it.

@github-actions
Copy link

Marking this stale since there has been no activity for 30 days.
It will be closed if there is no activity for another 15 days.

@SuperWangKai
Copy link
Contributor

#2779

@SuperWangKai
Copy link
Contributor

Hi guys, please help validate the PR.

@SuperWangKai
Copy link
Contributor

I have EP_HIGH_DPI=false-related issues in Web, too.
Does anybody know what exactly EP_HIGH_DPI is supposed to do?

Just searched around in ThirdParty/SDL folder -

Mac OS X:
* Added support for retina displays:
  Create your window with the SDL_WINDOW_ALLOW_HIGHDPI flag, and then use SDL_GL_GetDrawableSize() to find the actual drawable size. You are responsible for scaling mouse and drawing coordinates appropriately.
iOS:
* Added support for iOS 8
* The SDL_WINDOW_ALLOW_HIGHDPI window flag now enables high-dpi support, and SDL_GL_GetDrawableSize() or SDL_GetRendererOutputSize() gets the window resolution in pixels
 *  If the window is created with the SDL_WINDOW_ALLOW_HIGHDPI flag, its size
 *  in pixels may differ from its size in screen coordinates on platforms with
 *  high-DPI support (e.g. iOS and Mac OS X). Use SDL_GetWindowSize() to query
 *  the client area's size in screen coordinates, and SDL_GL_GetDrawableSize(),
 *  SDL_Vulkan_GetDrawableSize(), or SDL_GetRendererOutputSize() to query the
 *  drawable size in pixels.
 *  The window size in screen coordinates may differ from the size in pixels, if
 *  the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with
 *  high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or
 *  SDL_GetRendererOutputSize() to get the real client area size in pixels.
 *  The window size in screen coordinates may differ from the size in pixels, if
 *  the window was created with SDL_WINDOW_ALLOW_HIGHDPI on a platform with
 *  high-dpi support (e.g. iOS or OS X). Use SDL_GL_GetDrawableSize() or
 *  SDL_GetRendererOutputSize() to get the real client area size in pixels.

@SuperWangKai
Copy link
Contributor

This seems to be critical -

    SDL_WINDOW_ALLOW_HIGHDPI = 0x00002000,      /**< window should be created in high-DPI mode if supported.
                                                     On macOS NSHighResolutionCapable must be set true in the
                                                     application's Info.plist for this to have any effect. */

@ArnisLielturks

@SuperWangKai
Copy link
Contributor

This is how InputScale is set -
https://github.com/urho3d/Urho3D/blob/84913ce65b3aa0b8704a2e155d15e196dc572bdb/Source/Urho3D/Input/Input.cpp#L2422-L2432

To me, it the Input::inputScale_ is High DPI awared, but UI scale is just not.

In Editor's code, UI scale is set to be the same as Input Scale manually -
https://github.com/urho3d/Urho3D/blob/84913ce65b3aa0b8704a2e155d15e196dc572bdb/bin/Data/Scripts/Editor.as#L64-L74

I think the approach would be:

  • the High DPI should work (Input Scale is not ONE), otherwise it is a bug.
  • if we are not satisfied with the size of the UI, UI::SetScale is a workaround to set manually.

@1vanK 1vanK added the macos label Aug 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants