feat: Defer SDL initialization until window creation to support headless environments

This commit is contained in:
2026-01-04 13:55:32 +00:00
parent 4786a335aa
commit 92cec63072

View File

@@ -62,27 +62,7 @@ void SdlWindowService::Initialize() {
throw std::runtime_error("SdlWindowService already initialized");
}
// Check if SDL is already initialized
if (SDL_WasInit(0) == 0) {
try {
ThrowSdlErrorIfFailed(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO), "SDL_Init failed");
} catch (const std::exception& e) {
ShowErrorDialog("SDL Initialization Failed",
std::string("Failed to initialize SDL subsystems.\n\nError: ") + e.what());
throw;
}
} else {
logging::Logger::GetInstance().Info("SDL already initialized, skipping SDL_Init");
}
try {
ThrowSdlErrorIfFailed(SDL_Vulkan_LoadLibrary(nullptr), "SDL_Vulkan_LoadLibrary failed");
} catch (const std::exception& e) {
ShowErrorDialog("Vulkan Library Load Failed",
std::string("Failed to load Vulkan library. Make sure Vulkan drivers are installed.\n\nError: ") + e.what());
throw;
}
// Defer SDL initialization until window creation to avoid issues in headless environments
initialized_ = true;
// Publish application started event