Skip to content
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

Blurry on Retina Display on macOS #30

Closed
yurivish opened this issue Oct 25, 2016 · 6 comments
Closed

Blurry on Retina Display on macOS #30

yurivish opened this issue Oct 25, 2016 · 6 comments

Comments

@yurivish
Copy link

yurivish commented Oct 25, 2016

Hi!

This library looks fantastic. I was just playing with it and noticed there's a blur when used on a Retina Macbook Pro (mid-2012) – do you have an idea why?

My scaling setting is set to X1, and here's what a screenshot looks like of a black screen with a single pixel set to white:

screenshot 2016-10-25 00 34 17

And here it is again zoomed in:

screenshot 2016-10-25 00 36 11

You can see little 'wings' off to each of the four sides. Is this intentional, or a bug?

@yurivish yurivish changed the title Blurry on Retina Display Blurry on Retina Display on OS X Oct 25, 2016
@yurivish yurivish changed the title Blurry on Retina Display on OS X Blurry on retina display on OS X Oct 25, 2016
@yurivish yurivish changed the title Blurry on retina display on OS X Blurry on Retina Display on OS X Oct 25, 2016
@emoon
Copy link
Owner

emoon commented Oct 25, 2016

Hi,

Thank for the report.

This isn't expected but I'm not sure where the issue actually is I would guess it could be caused by 3 things.

  1. The display area (where the pixels are set) isn't correctly calculated and have "off by one" error (meaning that a 320x200 area might be 319x199 or similar) that would cause some slight scaling of the image.
  2. The code here https://github.com/emoon/rust_minifb/blob/master/src/native/macosx/OSXWindowFrameView.m#L25 always some some kind of filtering which should be disabled.
  3. I'm unsure of exactly how retina will affect single pixels like this as Retina will essentially "scale" the screen. Do you think you can try to disable Retina (go to 1:1 mode) and see if the issue is still there?

@yurivish
Copy link
Author

Hey! Thanks for the quick response.

It's gone if I switch to 2880x1800:

screenshot 2016-10-25 01 10 44

@yurivish
Copy link
Author

yurivish commented Oct 25, 2016

(that's a big square, not a single pixel; I wrote a little function to draw squares... but they're still blurry at my usual resolution:

screenshot 2016-10-25 01 12 53
)

@floooh
Copy link

floooh commented Oct 25, 2016

I've seen similar behaviour in my own 3D engine (noticeable with text rendering which I never could get crisp) and also in browsers before, the reason there was that the CALayer class defaults to linear filtering when composing the layer image in the window system.

See CALayer and search for 'filter' (there are several properties, but the one that made the difference was the magnificationFilter).

For instance in my code, I'm getting the layer from an MTKView object, and set the magnification filter, this fixed the blurriness:

[[bridge->mtkView layer] setMagnificationFilter:kCAFilterNearest];

Here's the related browser bug for Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=602103

Hope this helps :)

@emoon
Copy link
Owner

emoon commented Oct 25, 2016

Thanks! I will see if I can apply something similar to my code.

@emoon emoon changed the title Blurry on Retina Display on OS X Blurry on Retina Display on macOS Oct 25, 2016
@emoon
Copy link
Owner

emoon commented Oct 23, 2018

Hi, I have rewritten the macOS support to use Metal instead. I haven't looked in detail on this issue but let me know if it helps out. I will close this for now but if it doesn't work correctly please re-open it again.

@emoon emoon closed this as completed Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants