From 0c6cc36b806f1ef2cb75b650ed93210d446e3af6 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 27 May 2014 21:47:06 +0300 Subject: Refactor a bit video system initialisation. --- src/client.cpp | 85 +++++++++++++++++++++++++++------------------------------- 1 file changed, 39 insertions(+), 46 deletions(-) (limited to 'src/client.cpp') diff --git a/src/client.cpp b/src/client.cpp index 2af0eb84d..86f0d2f20 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -175,7 +175,6 @@ KeyboardConfig keyboard; UserPalette *userPalette = nullptr; SoundManager soundManager; -RenderType openGLMode = RENDER_SOFTWARE; volatile bool runCounters; bool isSafeMode = false; @@ -364,35 +363,30 @@ void Client::gameInit() #ifdef WIN32 extractDataDir(); mountDataDir(); +#endif + setIcon(); checkConfigVersion(); logVars(); Cpu::detect(); +#if defined(USE_OPENGL) +#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__) + if (!mOptions.safeMode && mOptions.test.empty() + && !config.getBoolValue("videodetected")) + { + graphicsManager.detectVideoSettings(); + } +#endif +#endif + updateEnv(); initGraphics(); -#else - setIcon(); - checkConfigVersion(); - logVars(); - Cpu::detect(); - initGraphics(); + +#ifndef WIN32 extractDataDir(); mountDataDir(); #endif - if (mOptions.dataPath.empty() - && !branding.getStringValue("dataPath").empty()) - { - if (isRealPath(branding.getStringValue("dataPath"))) - { - mOptions.dataPath = branding.getStringValue("dataPath"); - } - else - { - mOptions.dataPath = branding.getDirectory().append(dirSeparator) - + branding.getStringValue("dataPath"); - } - mOptions.skipUpdate = true; - } + updateDataPath(); // Add the main data directories to our PhysicsFS search path if (!mOptions.dataPath.empty()) @@ -541,18 +535,8 @@ void Client::createWindows() didYouKnowWindow->postInit(); } -void Client::initGraphics() +void Client::updateEnv() { -#if defined(USE_OPENGL) -#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__) - if (!mOptions.safeMode && mOptions.test.empty() - && !config.getBoolValue("videodetected")) - { - graphicsManager.detectVideoSettings(); - } -#endif -#endif - #if defined(WIN32) || defined(__APPLE__) if (config.getBoolValue("centerwindow")) setEnv("SDL_VIDEO_CENTERED", "1"); @@ -564,21 +548,30 @@ void Client::initGraphics() setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "1"); else setEnv("SDL_VIDEO_ALLOW_SCREENSAVER", "0"); +} + +void Client::updateDataPath() +{ + if (mOptions.dataPath.empty() + && !branding.getStringValue("dataPath").empty()) + { + if (isRealPath(branding.getStringValue("dataPath"))) + { + mOptions.dataPath = branding.getStringValue("dataPath"); + } + else + { + mOptions.dataPath = branding.getDirectory().append(dirSeparator) + + branding.getStringValue("dataPath"); + } + mOptions.skipUpdate = true; + } +} + +void Client::initGraphics() +{ + graphicsManager.initGraphics(mOptions.noOpenGL); - openGLMode = intToRenderType(config.getIntValue("opengl")); -#ifdef USE_OPENGL - OpenGLImageHelper::setBlur(config.getBoolValue("blur")); - SurfaceImageHelper::SDLSetEnableAlphaCache( - config.getBoolValue("alphaCache") && !openGLMode); - ImageHelper::setEnableAlpha(config.getFloatValue("guialpha") != 1.0F - || openGLMode); -#else - SurfaceImageHelper::SDLSetEnableAlphaCache( - config.getBoolValue("alphaCache")); - ImageHelper::setEnableAlpha(config.getFloatValue("guialpha") != 1.0F); -#endif - graphicsManager.createRenderers(mOptions.noOpenGL); - graphicsManager.detectPixelSize(); runCounters = config.getBoolValue("packetcounters"); applyVSync(); graphicsManager.setVideoMode(); -- cgit v1.2.3-60-g2f50