tmewett / BrogueCE

Brogue: Community Edition - a community-lead fork of the much-loved minimalist roguelike game
https://sites.google.com/site/broguegame/
GNU Affero General Public License v3.0
1.02k stars 108 forks source link

Rendering is low-res/pixelated on macOS #84

Closed akemn closed 3 years ago

akemn commented 4 years ago

On macOS 10.15.4, rendering is quite pixelated and low-resolution, compared with original Brogue. See screenshots below.

LEFT: Brogue 1.7.5 =====> RIGHT: BrogueCE 1.8.3 brogue175 mac 2brogueCE 183 mac 2

brogue175 macbrogueCE183 mac

Edit: Note that if not on a high-DPI display, you may need to zoom in on this page (cmd+ or ctrl+) to make the difference obvious.

tmewett commented 4 years ago

Curiouser and curiouser... when I start Brogue with the largest font size on my normal-DPI screen, it doesn't look nearly as bad as the attached image. I think SDL is doing something weird here.

Could you help me by answering these questions? (Any reader with the same issue can do the same)

  1. What resolution is your display?
  2. Do you have a display scale/zoom set in your system preferences? If so, what level is it?
  3. Does the pixellation persist at smaller font sizes (press '-')?
  4. Press '+' until you reach the largest font size - roughly how big is the game window compared to your display?
akemn commented 4 years ago
  1. What resolution is your display?

2560x1600 and 227ppi, but scaled to "look like" 1440x900. This is the default macbook air "retina" display config.

  1. Do you have a display scale/zoom set in your system preferences? If so, what level is it?

Yes, it is set to default: "looks like 1440x900"

  1. Does the pixellation persist at smaller font sizes (press '-')?

Interesting! Yes it does...until the text changes to a different font for the three smallest sizes. Those three use a different font that looks blocky but crisp, except for the "musical note" glyph. Screenshots: Screen Shot 2020-05-18 at 11 37 47 AMScreen Shot 2020-05-18 at 11 38 13 AM Notice the "musical note" symbol in the first screenshot -- still having the same problem as in larger font sizes.

  1. Press '+' until you reach the largest font size - roughly how big is the game window compared to your display?

I cannot seem to reach the maximum font size? The window continues getting larger until it fills the screen. Actually it goes slightly wider than the screen width. If I then continue pressing '+', it loops between three views where the left padding (space from window edge to where your '@' is shown) is -- guesstimating here -- [10, 5, 0] char widths.

Please let me know if I can help provide any other info or clarification.

tmewett commented 4 years ago

Ah ok!! That screenshot of the lower font size has explained what's going on, thank you!

It appears SDL window surface "pixels" are actually 2x2 blocks of physical pixels on macOS. Apple seems to call these blocks "points" in their documentation:

When you run a high-resolution-savvy app on a high-resolution device, the text, vector drawing, and UI controls are sharp. This is due to the increased pixel density—pixels are smaller and there are more of them per unit area. Each point in user space is backed by four pixels.

The behaviour of Surfaces on DPI-aware windows is completely undocumented in SDL. Based on what we've worked out here, it seems like it's not actually possible to draw to the physical pixels.

How bad/noticeable is this pixelation is on a high-DPI display? Fixing it is possible but would complicate the current renderer.

akemn commented 4 years ago

Well, imho it looks bad. I'm sure part of it is being used to the normal-looking text in the 1.7.5 version. And of course all other text rendered on screen is not looking this way. I suppose this means the renderer has changed from vanilla?

tmewett commented 4 years ago

I suppose this means the renderer has changed from vanilla?

Yes, vanilla had a Mac-specific renderer that we've replaced with a more portable one.

benob commented 4 years ago

Linux is affected by the same problem on wayland/hidpi displays.

ghost commented 3 years ago

Windows 10 is also affected. When the "Make everything bigger" setting is set above 100%, Windows upscales the window using bilinear interpolation, making Brogue CE 1.9.2 terribly blurry.

Fortunately there is a simple workaround: right-click on Brogue.exe, open the Properties > Compatibility > "Change high DPI settings", and tick the "High DPI scaling override":

image

Then Brogue is beautiful again.

Edit: I submitted PR #205 for Windows builds, so that the workaround is not necessary.

tmewett commented 3 years ago

Fixed by the linked PR

jamesgecko commented 3 years ago

The linked PR only seems to fix it for Windows, not macOS?

ghost commented 3 years ago

@jamesgecko It fixes it on macOS too. If you are building it yourself, just make sure you run the Brogue.app bundle, not the bin/brogue binary. The bundle contains a setting (NSHighResolutionCapable in Info.plist) to inform macOS that the app is hidpi-aware. Which it is, thanks to SDL's hardware-accelerated renderers.

make clean
make MAC_APP=YES
make Brogue.app

You may also need to ensure that you have a recent version of SDL2. I'm not sure older versions fully support Catalina and Big Sur. Try with 2.0.12 at the least.

akemn commented 3 years ago

Wow, great work Antony et al. Very exciting.

Confirming this fix is not currently represented in any pre-built Release binaries?

tmewett commented 3 years ago

Correct - it will appear in 1.9.3