summaryrefslogtreecommitdiff
path: root/src
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
parentc70431d73da9c821cfedbd162c7d2447b7057459 (diff)
downloadplus-a80a1c69f8a5f4db88ade16e3b9d53f7b648be47.tar.gz
plus-a80a1c69f8a5f4db88ade16e3b9d53f7b648be47.tar.bz2
plus-a80a1c69f8a5f4db88ade16e3b9d53f7b648be47.tar.xz
plus-a80a1c69f8a5f4db88ade16e3b9d53f7b648be47.zip
Get from video detection texture compression and texture sampler modes.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp5
-rw-r--r--src/graphicsmanager.cpp39
-rw-r--r--src/graphicsmanager.h7
-rw-r--r--src/gui/setup_video.cpp13
-rw-r--r--src/test/testlauncher.cpp4
-rw-r--r--src/test/testmain.cpp12
-rw-r--r--src/test/testmain.h2
7 files changed, 61 insertions, 21 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 8a3f6f026..5bf560d32 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -514,10 +514,7 @@ void Client::gameInit()
if (!mOptions.safeMode && mOptions.test.empty()
&& !config.getBoolValue("videodetected"))
{
- config.setValue("videodetected", true);
- int val = graphicsManager.startDetection();
- if (val >= 0 && val <= 2)
- config.setValue("opengl", val);
+ graphicsManager.detectVideoSettings();
}
#endif
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;
+ }
+}
diff --git a/src/graphicsmanager.h b/src/graphicsmanager.h
index 51c9a9efc..2373e598f 100644
--- a/src/graphicsmanager.h
+++ b/src/graphicsmanager.h
@@ -37,6 +37,7 @@
#include "localconsts.h"
class Graphics;
+class TestMain;
struct FBOInfo;
@@ -49,9 +50,9 @@ class GraphicsManager final
void initGraphics(bool noOpenGL);
- int startDetection();
+ TestMain *startDetection();
- bool detectGraphics();
+ int detectGraphics();
bool supportExtension(const std::string &ext);
@@ -83,6 +84,8 @@ class GraphicsManager final
void updateLimits();
+ void detectVideoSettings();
+
Graphics *createGraphics();
void createTextureSampler();
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 5157f8e9f..35293fec4 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -50,6 +50,8 @@
#include "utils/gettext.h"
+#include "test/testmain.h"
+
#include <guichan/key.hpp>
#include <guichan/listmodel.hpp>
@@ -559,9 +561,14 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
else if (id == "detect")
{
- const int val = graphicsManager.startDetection();
- if (val >= 0 && val <= 2)
- mOpenGLDropDown->setSelected(val);
+ TestMain *test = graphicsManager.startDetection();
+ if (test)
+ {
+ const int val = test->getConfig().getValueInt("opengl", -1);
+ if (val >= 0 && val <= 2)
+ mOpenGLDropDown->setSelected(val);
+ delete test;
+ }
}
}
diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp
index 4352957ef..609198a97 100644
--- a/src/test/testlauncher.cpp
+++ b/src/test/testlauncher.cpp
@@ -172,6 +172,7 @@ int TestLauncher::testBatches()
file << mTest << std::endl;
file << batches << std::endl;
+ return 0;
}
int TestLauncher::testInternal()
@@ -226,9 +227,8 @@ int TestLauncher::testInternal()
int TestLauncher::testVideoDetection()
{
- graphicsManager.detectGraphics();
file << mTest << std::endl;
- file << config.getIntValue("opengl") << std::endl;
+ file << graphicsManager.detectGraphics() << std::endl;
return 0;
}
diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp
index 94914c41b..535cfebc4 100644
--- a/src/test/testmain.cpp
+++ b/src/test/testmain.cpp
@@ -195,17 +195,17 @@ int TestMain::exec(const bool testAudio)
*/
// if OpenGL implimentation is not good, disable it.
- if (!detectMode)
+ if (!(detectMode & 15))
openGLMode = 0;
writeConfig(openGLMode, rescaleTest[openGLMode],
- soundTest, info, batchSize);
+ soundTest, info, batchSize, detectMode);
return 0;
}
void TestMain::writeConfig(const int openGLMode, const int rescale,
const int sound, const std::string &info,
- const int batchSize)
+ const int batchSize, const int detectMode)
{
mConfig.init(Client::getConfigDirectory() + "/config.xml");
@@ -226,6 +226,12 @@ void TestMain::writeConfig(const int openGLMode, const int rescale,
// max batch size
// mConfig.setValue("batchsize", batchSize);
+ // additinal modes
+ mConfig.setValue("useTextureSampler",
+ static_cast<bool>(detectMode & 1024));
+ mConfig.setValue("compresstextures",
+ static_cast<bool>(detectMode & 2048));
+
// stats
mConfig.setValue("testInfo", info);
diff --git a/src/test/testmain.h b/src/test/testmain.h
index 3b3b3fbe0..2367b7d1b 100644
--- a/src/test/testmain.h
+++ b/src/test/testmain.h
@@ -61,7 +61,7 @@ class TestMain
void writeConfig(const int openGLMode, const int rescale,
const int sound, const std::string &info,
- const int batchSize);
+ const int batchSize, const int detectMode);
int readValue2(const int ver);