From 5079bc497650faa6b8b30fb4b9a30786ab14567c Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 22 Mar 2019 21:11:17 -0700 Subject: [PATCH] Fix SDL video initialization on Steam Link --- app/main.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/main.cpp b/app/main.cpp index a7304244..71a32b14 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -225,6 +225,8 @@ LONG WINAPI UnhandledExceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo) int main(int argc, char *argv[]) { + SDL_SetMainReady(); + // Set the app version for the QCommandLineParser's showVersion() command QCoreApplication::setApplicationVersion(VERSION_STR); @@ -305,6 +307,16 @@ int main(int argc, char *argv[]) // Register custom metatypes for use in signals qRegisterMetaType("NvApp"); +#ifdef HAVE_SLVIDEO + // Steam Link requires that we initialize video before creating our + // QGuiApplication in order to configure the framebuffer correctly. + if (SDL_InitSubSystem(SDL_INIT_VIDEO) != 0) { + SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, + "SDL_InitSubSystem(SDL_INIT_VIDEO) failed: %s", + SDL_GetError()); + } +#endif + QGuiApplication app(argc, argv); // Override the default palette to fix dialog rendering on Linux @@ -415,10 +427,9 @@ int main(int argc, char *argv[]) if (engine.rootObjects().isEmpty()) return -1; - SDL_SetMainReady(); - if (SDL_Init(SDL_INIT_TIMER) != 0) { + if (SDL_InitSubSystem(SDL_INIT_TIMER) != 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, - "SDL_Init() failed: %s", + "SDL_InitSubSystem(SDL_INIT_TIMER) failed: %s", SDL_GetError()); }