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
+++ b/pytouhou/lib/sdl.pyx
@@ -62,7 +62,7 @@ class SDLError(gui.Error):
 
 
 class SDL:
-    def __init__(self, sound=True):
+    def __init__(self, *, video=True, sound=True):
         self.sound = sound
 
     def __enter__(self):
@@ -70,7 +70,7 @@ class SDL:
 
         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
+++ b/scripts/pytouhou
@@ -286,7 +286,8 @@ def main(window, path, data, stage_num, 
             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)