Armaho
Armaho

Reputation: 37

Pygame wrong resolution on macOS

Recently, I’ve been using pygame and found out when I create a window using pygame.display.set_mode((0, 0), pygame.FULLSCREEN), it's shown in the wrong resolution. I have a 2560 × 1600 monitor, but the window is at 1440 × 900 (It's still fullscreen, but the image quality has been reduced).
It's been shown in the docs for pygame.display, I believe that the problem is caused by stretching:

Some display environments have an option for automatically stretching all windows. When this option is enabled, this automatic stretching distorts the appearance of the pygame window. In the pygame examples directory, there is example code (prevent_display_stretching.py) which shows how to disable this automatic stretching of the pygame display on Microsoft Windows (Vista or newer required).

and this answer to a similar question, shown that in windows the problem can be solved using the code below:

ctypes.windll.user32.SetProcessDPIAware()
true_res = (windll.user32.GetSystemMetrics(0),windll.user32.GetSystemMetrics(1))

screen = pygame.display.set_mode(true_res,pygame.Fullscreen)

Sadly, I don't know how to do a similar job in macOS.

Upvotes: 1

Views: 751

Answers (2)

Armaho
Armaho

Reputation: 37

I've been able to work this problem out in the fullscreen mode using the code below:

screen = pygame.display.set_mode((2560, 1600), pygame.FULLSCREEN | pygame.SCALE)

Still don't know how to solve this under other circumstances, so I remain the question open.

Upvotes: 1

you can maybe ask the user what his resolution is from a drop-down menu and save that variable in a text file then set the screen width and height to the contexts of that text file

Upvotes: 0

Related Questions