dingusppc icon indicating copy to clipboard operation
dingusppc copied to clipboard

Enable HiDPI mode for SDL and ensure that we use nearest-neighbor scaling

Open mihaip opened this issue 1 year ago • 8 comments

Avoids blurriness on macOS hosts with Retina displays.

Before After
image image

mihaip avatar Oct 27 '24 18:10 mihaip

@dingusdev or anyone else: would appreciate testing to make sure this doesn't regress on a Windows or Linux host.

mihaip avatar Oct 27 '24 18:10 mihaip

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:

  1. use floor(scale) with nearest neighbour scaling.
  2. use float scale with current blurry scaling.

At a minimum, there should be a command line argument to select previous method and new method.

joevt avatar Oct 27 '24 23:10 joevt

or a DPPC debugger command to switch modes until we get a GUI to do the job.

joevt avatar Oct 27 '24 23:10 joevt

No regressions noticed. Also, there should be a command line arg to switch between methods, as joevt suggested.

dingusdev avatar Oct 27 '24 23:10 dingusdev

Actually, the new code doesn't add arbitrary scaling yet so perhaps the command line arg can be added later when that happens.

joevt avatar Oct 28 '24 00:10 joevt

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.

mihaip avatar Oct 28 '24 03:10 mihaip

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?

joevt avatar Oct 28 '24 12:10 joevt

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.

mihaip avatar Oct 28 '24 19:10 mihaip

I tweaked this to allow the smooth scaling to be re-enabled via Control-S. I think this should be a strict improvement now.

mihaip avatar Nov 09 '24 23:11 mihaip