this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added a couple of internal flags to keep better track of SDL initialization.

+24 -13
+24 -13
src/SDL_gpu.c
··· 66 66 static GPU_InitFlagEnum _gpu_preinit_flags = GPU_DEFAULT_INIT_FLAGS; 67 67 static GPU_InitFlagEnum _gpu_required_features = 0; 68 68 69 + static Uint8 _gpu_initialized_SDL_core = 0; 70 + static Uint8 _gpu_initialized_SDL = 0; 71 + 69 72 static int (*_gpu_print)(GPU_LogLevelEnum log_level, const char* format, va_list args) = &gpu_default_print; 70 73 71 74 ··· 179 182 180 183 static Uint8 gpu_init_SDL(void) 181 184 { 182 - if(GPU_GetNumActiveRenderers() == 0) 185 + if(!_gpu_initialized_SDL) 183 186 { 184 - Uint32 subsystems = SDL_WasInit(SDL_INIT_EVERYTHING); 185 - if(!subsystems) 187 + if(!_gpu_initialized_SDL_core && !SDL_WasInit(SDL_INIT_EVERYTHING)) 186 188 { 187 189 // Nothing has been set up, so init SDL and the video subsystem. 188 190 if(SDL_Init(SDL_INIT_VIDEO) < 0) ··· 190 192 GPU_PushErrorCode("GPU_Init", GPU_ERROR_BACKEND_ERROR, "Failed to initialize SDL video subsystem"); 191 193 return 0; 192 194 } 195 + _gpu_initialized_SDL_core = 1; 193 196 } 194 - else if(!(subsystems & SDL_INIT_VIDEO)) 197 + 198 + // SDL is definitely ready now, but we're going to init the video subsystem to be sure that SDL_gpu keeps it available until GPU_Quit(). 199 + if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) 195 200 { 196 - // Something already set up SDL, so just init video. 197 - if(SDL_InitSubSystem(SDL_INIT_VIDEO) < 0) 198 - { 199 - GPU_PushErrorCode("GPU_Init", GPU_ERROR_BACKEND_ERROR, "Failed to initialize SDL video subsystem"); 200 - return 0; 201 - } 201 + GPU_PushErrorCode("GPU_Init", GPU_ERROR_BACKEND_ERROR, "Failed to initialize SDL video subsystem"); 202 + return 0; 202 203 } 204 + _gpu_initialized_SDL = 1; 203 205 } 204 206 return 1; 205 207 } ··· 643 645 _gpu_window_mappings_size = 0; 644 646 _gpu_num_window_mappings = 0; 645 647 646 - if(GPU_GetNumActiveRenderers() == 0) 647 - SDL_Quit(); 648 + gpu_free_renderer_register(); 648 649 649 - gpu_free_renderer_register(); 650 + if(_gpu_initialized_SDL) 651 + { 652 + SDL_QuitSubSystem(SDL_INIT_VIDEO); 653 + _gpu_initialized_SDL = 0; 654 + 655 + if(_gpu_initialized_SDL_core) 656 + { 657 + SDL_Quit(); 658 + _gpu_initialized_SDL_core = 0; 659 + } 660 + } 650 661 } 651 662 652 663 void GPU_SetDebugLevel(GPU_DebugLevelEnum level)