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

CapabilitiesGetScreenDPI on Mac retina display concern #704

Open
codeservice opened this issue Dec 30, 2021 · 8 comments
Open

CapabilitiesGetScreenDPI on Mac retina display concern #704

codeservice opened this issue Dec 30, 2021 · 8 comments

Comments

@codeservice
Copy link
Contributor

I am not sure if this is an issue or something else because I don’t have Mac with Retina display and can’t check it, but periodically I have complains about screen DPI scale on this type of Mac only. Sizing of my app everywhere looks the same except Retina Mac. Could be issue with CapabilitiesGetScreenDPI method here. It would be great if someone can check this.

@codeservice
Copy link
Contributor Author

codeservice commented Dec 30, 2021

Also I have suggestions from developers for how we can support Retina Mac display:

  1. In the code where you initialize an NSOpenGLView you need to do this:

    [self setWantsBestResolutionOpenGLSurface:YES];

More details here:
https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/EnablingOpenGLforHighResolution/EnablingOpenGLforHighResolution.html

  1. In your app's Info.plist file you need to add this:

    <key>NSHighResolutionCapable</key>
    <true/>

Do we need this Retina display support in NME?

P.S. in case of SDL it can be missing flag:
SDL_WINDOW_ALLOW_HIGHDPI

https://stackoverflow.com/questions/17918921/retina-display-support-with-sdl

@hughsando
Copy link
Member

Yes, the current settings use a lower-res backbuffer on mac SDL, but the dpi should get reported relative to this backbuffer and so the font sizes can be made correct.
When the high DPI flag is added SDL_WINDOW_ALLOW_HIGHDPI, a few more adjustments need to be made to get the viewport, dpi and mouse coordinates correct.
There is working code in there for ios/android/windows but mac goes to some lengths to make getting the best resolution difficult.
Are you using a DPI scale for fonts etc? Do you set the app to high DPI mode yourself, or just use what nme uses?

@codeservice
Copy link
Contributor Author

I am using NME without high dpi flag and my app scaled using DPI. Users complained font size small other time that resolution to low.
It’s possible print DPI value from my app and user reported these values:
110.50000165954 - DPI
1440 - resX
900 - resY
Twice less then Retina display on Mac can provide.
https://support.apple.com/en-au/HT202471
I don’t have Retina display and can’t try any experiments here. Do you think NME need to support Mac high resolution DPI or current method acceptable?

@hughsando
Copy link
Member

I think both can be supported. I have been using NME on mac with the OS background scaling and I use nme.ui.Scale.getFontScale(); and things generally seem good. But I will add the Hires as an option (or maybe default) like it is on IOS because it makes me a bit sad to have unused resolution. There may be some performance implications - bit not too sure if it will be noticeable.

@codeservice
Copy link
Contributor Author

Thanks! User who asked for high resolution support, promise me to provide complete testing for new app version, because I don’t have this type of Mac. Hope it will work well and performance not downgrade to much.

@hughsando
Copy link
Member

So I have added an nmml flag, like <window highDpi="true" /> which does make things look better on a macbook.
You should probably check your font scales etc. but you may have already have done this on IOS.
One thing to watch out for is SDL window sizes are in "virtual pixels" so your render pixels may not match in some of the SDL window API calls if you are using them directly (or indirectly in a way I have not tested)

@codeservice
Copy link
Contributor Author

Checked on my old Mac(highDpi="true"). Everything works as before with this. Going to send app for testing on Retina display when its ready. Wondering if 3D rendering going to work properly. Will see how user respond.
Thank you for including this high res support in NME!

@codeservice
Copy link
Contributor Author

So I have response from user after testing high res DPI feature:

"This version is better, but still has a few problems.
As mentioned in an earlier email, the app's Info.plist file needs this:

<key>NSHighResolutionCapable</key>
<true/>

Without this, the app will only open in Low Resolution mode. After adding this
setting to your app it correctly opens in High Resolution mode on a Retina display.
(Note that it can also be switched to open in Low Res mode by selecting the app in the
Finder, choosing File > Get info and ticking the appropriate box.)"

and more:

screenDPI = 221.00000331909
screenResolutionX = 1440 (should be 2880?)
screenResolutionY = 900 (should be 1800?)

Everything else seams works correctly 2D and 3D app graphics renders correctly.

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