Fix display initialization

This commit is contained in:
Nahuel Lofeudo 2022-12-18 10:16:56 +00:00
parent eec2311014
commit 2f5001e70f
1 changed files with 3 additions and 12 deletions

15
main.py
View File

@ -99,18 +99,9 @@ def clear_screen() -> None:
def init_screen(width: int, height: int) -> pygame.Surface: def init_screen(width: int, height: int) -> pygame.Surface:
""" Create a Surface to draw on, with the given size, using either X11/Wayland (desktop) or directfb (no desktop) """ """ Create a Surface to draw on, with the given size, using either X11/Wayland (desktop) or directfb (no desktop) """
drivers = ['x11', 'directfb'] pygame.display.init()
for driver in drivers: window = pygame.display.set_mode((0, 0))
print(f'Trying driver {driver}') return window
# Make sure that SDL_VIDEODRIVER is set
os.putenv('SDL_VIDEODRIVER', driver)
try:
pygame.display.init()
window = pygame.display.set_mode(size=(width, height), flags=DOUBLEBUF)
except pygame.error:
continue
return window
raise Exception('No suitable video driver found!')
def main(): def main():