FrontendCommon: Use SDL_InitSubSystem() for lazy initialization
This commit is contained in:
21
src/frontend-common/sdl_initializer.cpp
Normal file
21
src/frontend-common/sdl_initializer.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "sdl_initializer.h"
|
||||
#include "common/assert.h"
|
||||
#include <SDL.h>
|
||||
|
||||
namespace FrontendCommon {
|
||||
static bool s_sdl_initialized = false;
|
||||
|
||||
void EnsureSDLInitialized()
|
||||
{
|
||||
if (s_sdl_initialized)
|
||||
return;
|
||||
|
||||
if (SDL_Init(0) < 0)
|
||||
{
|
||||
Panic("SDL_Init(0) failed");
|
||||
return;
|
||||
}
|
||||
|
||||
s_sdl_initialized = true;
|
||||
}
|
||||
} // namespace FrontendCommon
|
||||
Reference in New Issue
Block a user