summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-27 21:47:06 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-27 21:47:06 +0300
commit0c6cc36b806f1ef2cb75b650ed93210d446e3af6 (patch)
treec12988de642db84d6cf6108668310536390fdc5e
parenta1b59326cb4cd70bb2347e9776965a2a0d4895fd (diff)
downloadmv-0c6cc36b806f1ef2cb75b650ed93210d446e3af6.tar.gz
mv-0c6cc36b806f1ef2cb75b650ed93210d446e3af6.tar.bz2
mv-0c6cc36b806f1ef2cb75b650ed93210d446e3af6.tar.xz
mv-0c6cc36b806f1ef2cb75b650ed93210d446e3af6.zip
Refactor a bit video system initialisation.
-rw-r--r--src/client.cpp85
-rw-r--r--src/client.h4
-rw-r--r--src/graphicsmanager.cpp20
-rw-r--r--src/graphicsmanager.h2
4 files changed, 65 insertions, 46 deletions
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();
diff --git a/src/client.h b/src/client.h
index 3d414d466..18021b331 100644
--- a/src/client.h
+++ b/src/client.h
@@ -310,8 +310,12 @@ private:
void initGraphics();
+ void updateEnv();
+
void initTitle();
+ void updateDataPath();
+
static void extractDataDir();
void mountDataDir();
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 8dffafeb4..cb546e752 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -92,6 +92,8 @@
GraphicsManager graphicsManager;
+RenderType openGLMode = RENDER_SOFTWARE;
+
const int densitySize = 6;
const std::string densityNames[] =
@@ -414,6 +416,24 @@ void GraphicsManager::setVideoMode()
}
}
+void GraphicsManager::initGraphics(const bool 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
+ createRenderers(noOpenGL);
+ detectPixelSize();
+}
+
#ifdef USE_SDL2
SDL_Window *GraphicsManager::createWindow(const int w, const int h,
const int bpp A_UNUSED,
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index 991d7e63b..6fe51795f 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -78,6 +78,8 @@ class GraphicsManager final
void createRenderers(const bool noOpenGL);
+ void initGraphics(const bool noOpenGL);
+
static void setVideoMode();
SDL_Window *createWindow(const int w, const int h,