Fix display initialization
This commit is contained in:
parent
eec2311014
commit
2f5001e70f
15
main.py
15
main.py
|
|
@ -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():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue