Enable HiDPI mode for SDL and ensure that we use nearest-neighbor scaling
Avoids blurriness on macOS hosts with Retina displays.
| Before | After |
|---|---|
@dingusdev or anyone else: would appreciate testing to make sure this doesn't regress on a Windows or Linux host.
I like it. But, this is only good for integer scaling. It will not look good if you're trying to scale 1024x768 full screen to a 1440p or 4K display. We'll want a method to avoid the issues described at https://www.emaculation.com/forum/viewtopic.php?t=12173
Fullscreen mode options:
- use
floor(scale)with nearest neighbour scaling. - use
float scalewith current blurry scaling.
At a minimum, there should be a command line argument to select previous method and new method.
or a DPPC debugger command to switch modes until we get a GUI to do the job.
No regressions noticed. Also, there should be a command line arg to switch between methods, as joevt suggested.
Actually, the new code doesn't add arbitrary scaling yet so perhaps the command line arg can be added later when that happens.
Yes, this does not add any new arbitrary scaling options. In any case, per https://wiki.libsdl.org/SDL2/SDL_HINT_RENDER_SCALE_QUALITY the default for scaling is nearest neighbor, so the SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0") call should be a no-op, just wanted it to the explicit.
Yes, this does not add any new arbitrary scaling options. In any case, per https://wiki.libsdl.org/SDL2/SDL_HINT_RENDER_SCALE_QUALITY the default for scaling is nearest neighbor, so the
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0")call should be a no-op, just wanted it to the explicit.
If the default is nearest neighbor, then why does the upstream have blurriness? The only thing you changed otherwise is SDL_WINDOW_ALLOW_HIGHDPI. Does not having that use different scaling?
I believe the scaling is done by Cocoa/AppKit. When SDL_WINDOW_ALLOW_HIGHDPI is not enabled, the view that SDL creates is at the logical resolution, and gets scaled by macOS.
I tweaked this to allow the smooth scaling to be re-enabled via Control-S. I think this should be a strict improvement now.