Mercurial > touhou
comparison pytouhou/lib/sdl.pyx @ 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 | 80687f258001 |
children | 468dab1dd683 |
comparison
equal
deleted
inserted
replaced
753:a662dddd4a2b | 754:a6875f90c141 |
---|---|
60 error = SDL_GetError() | 60 error = SDL_GetError() |
61 Exception.__init__(self, error.decode()) | 61 Exception.__init__(self, error.decode()) |
62 | 62 |
63 | 63 |
64 class SDL: | 64 class SDL: |
65 def __init__(self, sound=True): | 65 def __init__(self, *, video=True, sound=True): |
66 self.sound = sound | 66 self.sound = sound |
67 | 67 |
68 def __enter__(self): | 68 def __enter__(self): |
69 global keyboard_state | 69 global keyboard_state |
70 | 70 |
71 IF UNAME_SYSNAME == "Windows": | 71 IF UNAME_SYSNAME == "Windows": |
72 SDL_SetMainReady() | 72 SDL_SetMainReady() |
73 init(SDL_INIT_VIDEO) | 73 init(SDL_INIT_VIDEO if video else 0) |
74 img_init(IMG_INIT_PNG) | 74 img_init(IMG_INIT_PNG) |
75 ttf_init() | 75 ttf_init() |
76 | 76 |
77 keyboard_state = SDL_GetKeyboardState(NULL) | 77 keyboard_state = SDL_GetKeyboardState(NULL) |
78 | 78 |