Make SDL Init on the Main Thread

This commit is contained in:
stossy11 2024-11-02 11:42:28 +11:00
parent f632f16449
commit 60cfb86774
2 changed files with 12 additions and 10 deletions

View File

@ -21,16 +21,18 @@ struct ContentView: View {
@State var debugmode: Int = 0
init() {
SDL_SetMainReady()
SDL_iPhoneSetEventPump(SDL_TRUE)
if SDL_Init(SDL_INIT_VIDEO) < 0 {
fatalError("Unable to initialize SDL: \(String(cString: SDL_GetError()))")
}
if SDL_Vulkan_LoadLibrary(nil) != 0 {
fatalError("Failed to load Vulkan library: \(String(cString: SDL_GetError()))")
DispatchQueue.main.async {
SDL_SetMainReady()
SDL_iPhoneSetEventPump(SDL_TRUE)
if SDL_Init(SDL_INIT_VIDEO) < 0 {
fatalError("Unable to initialize SDL: \(String(cString: SDL_GetError()))")
}
if SDL_Vulkan_LoadLibrary(nil) != 0 {
fatalError("Failed to load Vulkan library: \(String(cString: SDL_GetError()))")
}
}
}