changeset 754:a6875f90c141

Python: Only init SDL2 video if using SDL2 frontend.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 04 Jan 2021 20:39:30 +0100
parents a662dddd4a2b
children fc937d93a57c
files pytouhou/lib/sdl.pyx scripts/pytouhou
diffstat 2 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/lib/sdl.pyx	Tue Feb 25 21:03:44 2020 +0100
+++ b/pytouhou/lib/sdl.pyx	Mon Jan 04 20:39:30 2021 +0100
@@ -62,7 +62,7 @@
 
 
 class SDL:
-    def __init__(self, sound=True):
+    def __init__(self, *, video=True, sound=True):
         self.sound = sound
 
     def __enter__(self):
@@ -70,7 +70,7 @@
 
         IF UNAME_SYSNAME == "Windows":
             SDL_SetMainReady()
-        init(SDL_INIT_VIDEO)
+        init(SDL_INIT_VIDEO if video else 0)
         img_init(IMG_INIT_PNG)
         ttf_init()
 
--- a/scripts/pytouhou	Tue Feb 25 21:03:44 2020 +0100
+++ b/scripts/pytouhou	Mon Jan 04 20:39:30 2021 +0100
@@ -286,7 +286,8 @@
             save_replay.write(file)
 
 
-with SDL(sound=args.no_sound):
+is_sdl = (args.frontend == 'sdl')
+with SDL(video=is_sdl, sound=args.no_sound):
     window = Window(backend, Interface.width, Interface.height,
                     fps_limit=args.fps_limit, frameskip=args.frameskip)