Skip to content
Permalink
Browse files

Don't let a delayed config load mess with the GPU backend option. Fixes

  • Loading branch information...
hrydgard committed Sep 17, 2019
1 parent 1e20024 commit 4cebea6a143c661f737998d1423f27ac5a597012
Showing with 8 additions and 9 deletions.
  1. +8 −9 UI/NativeApp.cpp
@@ -514,6 +514,7 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
LogManager *logman = LogManager::GetInstance();

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

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


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

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

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

@@ -1101,9 +1094,15 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
#endif
// We must have failed to load the config before, so load it now to avoid overwriting the old config
// 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.");
g_Config.Load();
PostLoadConfig();
g_Config.iGPUBackend = gpuBackend;
}
}

0 comments on commit 4cebea6

Please sign in to comment.
You can’t perform that action at this time.