summaryrefslogtreecommitdiff
path: root/src/graphicsmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-27 03:35:10 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-27 03:35:10 +0300
commit7ed530350226d268c3ccb80952f4176589e9a32a (patch)
tree05c4d030d2c872ae458fd2606ec116c1a636e8b2 /src/graphicsmanager.cpp
parent10502e29937b67d5f2d62cf70804a4de76c5cf69 (diff)
downloadmv-7ed530350226d268c3ccb80952f4176589e9a32a.tar.gz
mv-7ed530350226d268c3ccb80952f4176589e9a32a.tar.bz2
mv-7ed530350226d268c3ccb80952f4176589e9a32a.tar.xz
mv-7ed530350226d268c3ccb80952f4176589e9a32a.zip
Autoselect resolution under android.
Diffstat (limited to 'src/graphicsmanager.cpp')
-rw-r--r--src/graphicsmanager.cpp52
1 files changed, 50 insertions, 2 deletions
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 67bfa8847..5abd85297 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -264,14 +264,31 @@ Graphics *GraphicsManager::createGraphics()
void GraphicsManager::setVideoMode()
{
- const int width = config.getIntValue("screenwidth");
- const int height = config.getIntValue("screenheight");
+ int width = config.getIntValue("screenwidth");
+ int height = config.getIntValue("screenheight");
const int bpp = 0;
const bool fullscreen = config.getBoolValue("screen");
const bool hwaccel = config.getBoolValue("hwaccel");
const bool enableResize = config.getBoolValue("enableresize");
const bool noFrame = config.getBoolValue("noframe");
+#ifdef ANDROID
+ StringVect videoModes;
+ getAllVideoModes(videoModes);
+ if (!videoModes.empty())
+ {
+ std::string str = videoModes[0];
+ std::vector<int> res;
+ splitToIntVector(res, videoModes[0], 'x');
+ if (res.size() == 2)
+ {
+ width = res[0];
+ height = res[1];
+ logger->log("Autoselect mode %dx%d", width, height);
+ }
+ }
+#endif
+
// Try to set the desired video mode
if (!mainGraphics->setVideoMode(width, height, bpp,
fullscreen, hwaccel, enableResize, noFrame))
@@ -302,6 +319,37 @@ void GraphicsManager::setVideoMode()
}
}
+bool GraphicsManager::getAllVideoModes(StringVect &modeList)
+{
+ /* Get available fullscreen/hardware modes */
+ SDL_Rect **const modes = SDL_ListModes(nullptr,
+ SDL_FULLSCREEN | SDL_HWSURFACE);
+
+ /* Check which modes are available */
+ if (modes == static_cast<SDL_Rect **>(nullptr))
+ {
+ logger->log1("No modes available");
+ return false;
+ }
+ else if (modes == reinterpret_cast<SDL_Rect **>(-1))
+ {
+ logger->log1("All resolutions available");
+ return true;
+ }
+ else
+ {
+ for (int i = 0; modes[i]; ++ i)
+ {
+ const std::string modeString =
+ toString(static_cast<int>(modes[i]->w)) + "x"
+ + toString(static_cast<int>(modes[i]->h));
+ logger->log("support mode: " + modeString);
+ modeList.push_back(modeString);
+ }
+ return true;
+ }
+}
+
#ifdef USE_OPENGL
void GraphicsManager::updateExtensions()
{