Skip to content

Commit

Permalink
Don't let a delayed config load mess with the GPU backend option. Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Sep 17, 2019
1 parent 1e20024 commit 4cebea6
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions UI/NativeApp.cpp
Expand Up @@ -514,6 +514,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
LogManager *logman = LogManager::GetInstance(); LogManager *logman = LogManager::GetInstance();


#ifdef __ANDROID__ #ifdef __ANDROID__
// On early versions of Android we don't need to ask permission.
CreateDirectoriesAndroid(); CreateDirectoriesAndroid();
#endif #endif


Expand Down Expand Up @@ -978,6 +979,7 @@ void NativeRender(GraphicsContext *graphicsContext) {
ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f); ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
break; break;
case GPUBackend::OPENGL: case GPUBackend::OPENGL:
default:
ortho.setOrtho(0.0f, xres, yres, 0.0f, -1.0f, 1.0f); ortho.setOrtho(0.0f, xres, yres, 0.0f, -1.0f, 1.0f);
break; break;
} }
Expand Down Expand Up @@ -1005,7 +1007,6 @@ void NativeRender(GraphicsContext *graphicsContext) {
uiContext->SetBounds(Bounds(0, 0, dp_xres, dp_yres)); uiContext->SetBounds(Bounds(0, 0, dp_xres, dp_yres));
// uiContext->SetBounds(Bounds(dp_xres/2, 0, dp_xres / 2, dp_yres / 2)); // uiContext->SetBounds(Bounds(dp_xres/2, 0, dp_xres / 2, dp_yres / 2));



// OSX 10.6 and SDL 1.2 bug. // OSX 10.6 and SDL 1.2 bug.
#if defined(__APPLE__) && !defined(USING_QT_UI) #if defined(__APPLE__) && !defined(USING_QT_UI)
static int dp_xres_old = dp_xres; static int dp_xres_old = dp_xres;
Expand All @@ -1016,14 +1017,6 @@ void NativeRender(GraphicsContext *graphicsContext) {
#endif #endif
} }


// Test lost/restore on PC
#if 0
if (gpu) {
gpu->DeviceLost();
gpu->DeviceRestore();
}
#endif

graphicsContext->Resize(); graphicsContext->Resize();
screenManager->resized(); screenManager->resized();


Expand Down Expand Up @@ -1101,9 +1094,15 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
#endif #endif
// We must have failed to load the config before, so load it now to avoid overwriting the old config // We must have failed to load the config before, so load it now to avoid overwriting the old config
// with a freshly generated one. // with a freshly generated one.
// NOTE: If graphics backend isn't what's in the config (due to error fallback, or not matching the default
// and then getting permission), it will get out of sync. So we save and restore g_Config.iGPUBackend.
// Ideally we should simply reinitialize graphics to the mode from the config, but there are potential issues
// and I can't risk it before 1.9.0.
int gpuBackend = g_Config.iGPUBackend;
ILOG("Reloading config after storage permission grant."); ILOG("Reloading config after storage permission grant.");
g_Config.Load(); g_Config.Load();
PostLoadConfig(); PostLoadConfig();
g_Config.iGPUBackend = gpuBackend;
} }
} }


Expand Down

0 comments on commit 4cebea6

Please sign in to comment.