简体   繁体   中英

How can I get PyGame's fullscreen mode to scale consistently on different computers?

In short: With the same python script and the same monitor, using PyGame in fullscreen mode produces two different sized images on two different computers.

I am trying to run a PyGame script on two computers, and I need the images displayed to match each other in size on both computers. Each computer has the same monitor. Without using fullscreen, the PyGame windows (and so the images of the surfaces displayed) are the same size. When using

pygame.display.set_mode((width,height),pygame.FULLSCREEN)

The images are the same size on both computers when the ratio of (width,height) matches the aspect ratio of the native resolution of my monitor. If I use a combination that is not on that list, for instance in my case (1250, 850), the images on the screen are scaled differently for each computer. The computers are fairly similar, however they do not have the same graphics adapter.

In the PyGame documentation we can find

When requesting fullscreen display modes, sometimes an exact match for the
requested resolution cannot be made. In these situations pygame will select
the closest compatible match.

Is PyGame picking a different match for each computer?

也许您可以使用pygame.display.list_modes ,这会告诉您全屏的分辨率是可能的

To answer the title question: use a display mode resolution that is a commonly supported aspect ratio.

The difference lies in the graphics adapter. The list of supported resolutions given by pygame.display.list_modes() depends on the adapter. In particular, the next highest resolution above (1250,850) was different for each adapter, so PyGame's fullscreen used a different "closest compatible match" on each computer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM