Fix for blurry high-dpi / retina window

About SheepShaver, a PPC Mac emulator for Windows, MacOS X, and Linux that can run System 7.5.3 to MacOS 9.0.4.

Moderators: Cat_7, Ronald P. Regensburg, ClockWise

Post Reply
DrLex
Tinkerer
Posts: 84
Joined: Sun Nov 19, 2006 6:01 pm
Location: Belgium

Fix for blurry high-dpi / retina window

Post by DrLex »

I have noticed that even with the ‘scale_nearest true’ option in the prefs, the SheepShaver window still looks blurry on a retina display. In fact, there is no visible difference between enabling that option or not, neither between forcing the app to low-resolution in the Finder or not. When making screenshots and viewing them at larger size, the blurriness becomes really obvious.

After some googling around, I have found that for SDL to truly render at the higher resolution, the flag ‘SDL_WINDOW_ALLOW_HIGHDPI’ must be passed to SDL_CreateWindow(). Without this, the window is rendered at regular resolution and it seems that the OS (or at least Mac OS X) then uses linear interpolation to obtain the higher resolution.
The result of combining scale_nearest with this flag can be seen below at the right. Anyone preferring the softer look can either disable scale_nearest or force the app to low res in the Finder.
Unless someone knows situations where enabling this can be problematic, I would just always enable it. Otherwise it will need to be toggle-able with a prefs setting.

Image
User avatar
adespoton
Forum All-Star
Posts: 4226
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Fix for blurry high-dpi / retina window

Post by adespoton »

Wow! Thanks for finding that; it's been bugging me for a while, but not enough for me to take the time to figure it out.

Paging kanjitalk755 for integration :D
DrLex
Tinkerer
Posts: 84
Joined: Sun Nov 19, 2006 6:01 pm
Location: Belgium

Re: Fix for blurry high-dpi / retina window

Post by DrLex »

Yes, initially I merely thought: “man, my eyesight isn't what it used to be!” Only when actually fixing it it became obvious how fuzzy the graphics were…
I simply added this at line 739 of BasiliskII/src/SDL/video_sdl2.cpp:

Code: Select all

window_flags |= SDL_WINDOW_ALLOW_HIGHDPI;
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Fix for blurry high-dpi / retina window

Post by Ronald P. Regensburg »

DrLex wrote:I simply added this at line 739 of BasiliskII/src/SDL/video_sdl2.cpp:

Code: Select all

window_flags |= SDL_WINDOW_ALLOW_HIGHDPI;
Did you do that in a recent version of the source from kanjitalk755/macemu?

Has the Info.plist file this as last entry (3 Feb added in kanjitalk755/macemu):
</dict>
<key>NSHighResolutionCapable</key>
<true/>
</dict>

Edit:
It seems that this entry in Info.plist causes problems with at least some Retina screens:
viewtopic.php?p=62270#p62270
viewtopic.php?f=20&t=10073
Last edited by Ronald P. Regensburg on Fri Feb 22, 2019 11:50 am, edited 2 times in total.
Reason:  
DrLex
Tinkerer
Posts: 84
Joined: Sun Nov 19, 2006 6:01 pm
Location: Belgium

Re: Fix for blurry high-dpi / retina window

Post by DrLex »

Ronald P. Regensburg wrote:Did you do that in a recent version of the source from kanjitalk755/macemu?
Yes, this is in the latest source. Dropping the NSHighResolutionCapable flag is not the way forward. That would only mask the true problem and take away the possibility of sharp rendering on retina displays. And we all know that someday Apple will drop support for low-resolution apps, like they are now doing with 32-bit.

Both the NSHighResolutionCapable flag in the plist and the SDL_WINDOW_ALLOW_HIGHDPI flag in the code are needed to make SDL2 render correctly in high resolution. Without the latter, the only thing you're gaining is a sharper preferences window. I have a suspicion the problem reported by ‘bestusername’ and ‘rganschow’ may be caused by only having the high resolution flag in the plist but not in the source code. There could be a bug in the version of the SDL2 framework that was used to create the build, triggering the exaggerated zoom. I'm building against SDL2-2.0.9 (Oct 31 2018) and cannot reproduce this problem with my builds. (I suspect that the bug wouldn't occur in the older SDL2 either when combining the plist and source code flags.)
User avatar
Ronald P. Regensburg
Expert User
Posts: 7821
Joined: Thu Feb 09, 2006 10:24 pm
Location: Amsterdam, Netherlands

Re: Fix for blurry high-dpi / retina window

Post by Ronald P. Regensburg »

DrLex wrote:I have a suspicion the problem reported by ‘bestusername’ and ‘rganschow’ may be caused by only having the high resolution flag in the plist but not in the source code.
That is what I suspected, hence my question. In the current kanjitalk755 source, the NSHighResolutionCapable flag is present in the plist but the the SDL_WINDOW_ALLOW_HIGHDPI flag is not in the code.
There could be a bug in the version of the SDL2 framework that was used to create the build, triggering the exaggerated zoom. I'm building against SDL2-2.0.9 (Oct 31 2018) and cannot reproduce this problem with my builds.
Also if the the SDL_WINDOW_ALLOW_HIGHDPI flag is not in the code?

(I cannot test different builds myself because I do not have a Retina screen and neither has kanjitalk755. The issue is only manifest on high-res screens.)

Edit: I used SDL2-2.0.8.
Last edited by Ronald P. Regensburg on Fri Feb 22, 2019 8:00 pm, edited 1 time in total.
Reason:  
Post Reply