Skip to content

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

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

Merged
merged 1 commit into from
Nov 9, 2024

Conversation

mihaip
Copy link
Contributor

@mihaip mihaip commented Oct 27, 2024

Avoids blurriness on macOS hosts with Retina displays.

Before After
image image

@mihaip
Copy link
Contributor Author

mihaip commented Oct 27, 2024

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

@joevt
Copy link
Contributor

joevt commented Oct 27, 2024

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
Copy link
Contributor

joevt commented Oct 27, 2024

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

@dingusdev
Copy link
Owner

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

@joevt
Copy link
Contributor

joevt commented Oct 28, 2024

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

@mihaip
Copy link
Contributor Author

mihaip commented Oct 28, 2024

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.

@joevt
Copy link
Contributor

joevt commented Oct 28, 2024

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?

@mihaip
Copy link
Contributor Author

mihaip commented Oct 28, 2024

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.

…ling

Avoids blurriness on macOS hosts with Retina displays.

Smooth scaling can be toggled back on via control-S
@mihaip
Copy link
Contributor Author

mihaip commented Nov 9, 2024

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

@dingusdev dingusdev merged commit 6766ca8 into dingusdev:master Nov 9, 2024
5 checks passed
@mihaip mihaip deleted the upstream-hidpi branch November 10, 2024 19:58
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

Successfully merging this pull request may close these issues.

3 participants