summaryrefslogtreecommitdiff
path: root/src/graphicsmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-08 17:11:06 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-08 17:11:06 +0300
commita80a1c69f8a5f4db88ade16e3b9d53f7b648be47 (patch)
treed8fe25f8aca2b62f2c93f7eb264eabffa85b8959 /src/graphicsmanager.cpp
parentc70431d73da9c821cfedbd162c7d2447b7057459 (diff)
downloadmv-a80a1c69f8a5f4db88ade16e3b9d53f7b648be47.tar.gz
mv-a80a1c69f8a5f4db88ade16e3b9d53f7b648be47.tar.bz2
mv-a80a1c69f8a5f4db88ade16e3b9d53f7b648be47.tar.xz
mv-a80a1c69f8a5f4db88ade16e3b9d53f7b648be47.zip
Get from video detection texture compression and texture sampler modes.
Diffstat (limited to 'src/graphicsmanager.cpp')
-rw-r--r--src/graphicsmanager.cpp39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 8e41f4666..21fea5738 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -85,22 +85,24 @@ GraphicsManager::~GraphicsManager()
#endif
}
-int GraphicsManager::startDetection()
+TestMain *GraphicsManager::startDetection()
{
#ifdef USE_OPENGL
TestMain *test = new TestMain();
test->exec(false);
- return test->getConfig().getValueInt("opengl", -1);
+ return test;
#else
- return 0;
+ return nullptr;
#endif
}
-bool GraphicsManager::detectGraphics()
+int GraphicsManager::detectGraphics()
{
#ifdef USE_OPENGL
logger->log("start detecting best mode...");
logger->log("enable opengl mode");
+ int textureSampler = 0;
+ int compressTextures = 0;
SDL_SetVideoMode(100, 100, 0, SDL_ANYFORMAT | SDL_OPENGL);
initOpenGL();
@@ -149,6 +151,7 @@ bool GraphicsManager::detectGraphics()
// hope it can work well
logger->log("detected NVIDIA driver");
config.setValue("useTextureSampler", true);
+ textureSampler = 1;
mode = 1;
}
@@ -164,6 +167,7 @@ bool GraphicsManager::detectGraphics()
{
// Mesa detected
config.setValue("compresstextures", true);
+ compressTextures = 1;
}
config.setValue("opengl", mode);
@@ -171,9 +175,9 @@ bool GraphicsManager::detectGraphics()
config.write();
logger->log("detection complete");
- return true;
+ return mode | (1024 * textureSampler) | (2048 * compressTextures);
#else
- return false;
+ return 0;
#endif
}
@@ -711,3 +715,26 @@ unsigned int GraphicsManager::getLastError()
}
return error;
}
+
+void GraphicsManager::detectVideoSettings()
+{
+ config.setValue("videodetected", true);
+ TestMain *test = startDetection();
+
+ if (test)
+ {
+ const Configuration &conf = test->getConfig();
+ int val = conf.getValueInt("opengl", -1);
+ if (val >= 0 && val <= 2)
+ {
+ config.setValue("opengl", val);
+ val = conf.getValue("useTextureSampler", -1);
+ if (val != -1)
+ config.setValue("useTextureSampler", val);
+ val = conf.getValue("compresstextures", -1);
+ if (val != -1)
+ config.setValue("compresstextures", val);
+ }
+ delete test;
+ }
+}