I am using pygame to create an application that needs a square screen, 800x800. It works fine when it's windowed i.e. when I simply do:
screen_width = 800
screen_height = 800
screen = pygame.display.set_mode((screen_width, screen_height))
or
flags = NOFRAME
screen = pygame.display.set_mode((screen_width, screen_height), flags)
But when I use the fullscreen flag, my game window gets stretched to a widescreen resolution, making it non-square and also stretched to fit in fullscreen. What I think it's doing is it's automatically picking the closest resolution from the list of supported resolutions:
print(pygame.display.list_modes())
[(1920, 1080), (1920, 1080), (1920, 1080), (1920, 1080), (1920, 1080), (1920, 1080), (1680, 1050), (1680, 1050), (1680, 1050), (1600, 900), (1600, 900), (1600, 900), (1440, 900), (1440, 900), (1440, 900), (1440, 576), (1440, 576), (1440, 576), (1440, 576), (1440, 480), (1440, 480), (1440, 480), (1440, 480), (1440, 480), (1400, 1050), (1400, 1050), (1400, 1050), (1366, 768), (1366, 768), (1366, 768), (1360, 768), (1360, 768), (1360, 768), (1280, 1024), (1280, 1024), (1280, 1024), (1280, 1024), (1280, 960), (1280, 960), (1280, 960), (1280, 800), (1280, 800), (1280, 800), (1280, 768), (1280, 768), (1280, 768), (1280, 720), (1280, 720), (1280, 720), (1280, 600), (1280, 600), (1280, 600), (1152, 864), (1152, 864), (1152, 864), (1152, 864), (1024, 768), (1024, 768), (1024, 768), (1024, 768), (800, 600), (800, 600), (800, 600), (800, 600), (720, 576), (720, 576), (720, 576), (720, 480), (720, 480), (720, 480), (640, 480), (640, 480), (640, 480), (640, 480), (640, 400), (640, 400), (640, 400), (512, 384), (512, 384), (512, 384), (400, 300), (400, 300), (400, 300), (320, 240), (320, 240), (320, 240), (320, 200), (320, 200), (320, 200)]
But what I'd like it to do is for the window to remain unstretched i.e. remain in the same size as it is as using the pygame.NOFRAME flag or no flag, and to remain square (1:1 aspect ratio). I need it to be fullscreen, so the areas outside the 800x800 window can just be black areas.
I've looked around but I can't find a way to avoid this automatic adjustment that pygame does when going fullscreen. I'd appreciate any help.


