mirror of
https://github.com/johndoe6345789/SDL3CPlusPlus.git
synced 2026-04-24 13:44:58 +00:00
feat: Defer SDL initialization until window creation to support headless environments
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user