Can Python and Pygame detect the video mode/resolution my screen is
I'm making my program run in full screen at 1920x1080 and this will work fine as I have a 16:9 screen @ 1920x1080 however if I run the code on a 4:3 screen @ 1024x768 then it gives me this error messgae
pygame.error: No video mode large enough for 1920x1080
Can pygame detect the video mode/resolution of the screen?
If you need the actual size of the display, not the best resolution to use, you do:
import pygame
pygame.display.init()
# Before calling *.set_mode()
i = pygame.display.Info()
width = i.current_w
height = i.current_h
print("The screen size is: (%ix%i)" %width, height))
Then you can use width and height to pygame.display.set_mode()
Yes, it seems pygame can detect various settings in your display.
The first place to look is this link here, reading it should give you a lot of information on how pygame can help you with display modes. The How to Decide section will probably be most useful to you.
After reading that you should find yourself moving onto this link here. You will see in the fourth paragraph after the links:
If precise control is needed over the pixel format or display resolutions, use the functions pygame.display.mode_ok(), pygame.display.list_modes(), and pygame.display.Info() to query information about the display.
So it'd be best to read up on how to use and play around with them to see how the information is returned and used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With