diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-04-30 22:32:38 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-01 17:27:14 +0300 |
commit | 097b17e588ed430482fa1e5e4938618db838e468 (patch) | |
tree | adb9f3122b1e5fac635e439c722ed983ae36d289 /src/graphicsmanager.cpp | |
parent | 1889feb70ddd6d1eaa33da7584ecd20955f94f5c (diff) | |
download | plus-097b17e588ed430482fa1e5e4938618db838e468.tar.gz plus-097b17e588ed430482fa1e5e4938618db838e468.tar.bz2 plus-097b17e588ed430482fa1e5e4938618db838e468.tar.xz plus-097b17e588ed430482fa1e5e4938618db838e468.zip |
add pixel size detection fo X11 and windows.
Diffstat (limited to 'src/graphicsmanager.cpp')
-rw-r--r-- | src/graphicsmanager.cpp | 91 |
1 files changed, 69 insertions, 22 deletions
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp index 7c5c94ed6..52006ad6c 100644 --- a/src/graphicsmanager.cpp +++ b/src/graphicsmanager.cpp @@ -27,9 +27,12 @@ #include <GLES2/gl2.h> #include <GLES/glext.h> #include <EGL/egl.h> +#include <SDL_android.h> #else #include "GL/glx.h" #endif +#else +//#include <winuser.h> #endif #endif @@ -76,6 +79,18 @@ GraphicsManager graphicsManager; +const int densitySize = 6; + +const std::string densityNames[] = +{ + "low", + "medium", + "tv", + "high", + "xhigh", + "xxhigh" +}; + GraphicsManager::GraphicsManager() : mExtensions(), mPlatformExtensions(), @@ -88,6 +103,11 @@ GraphicsManager::GraphicsManager() : mPlatformMajor(0), mMaxVertices(500), mMaxFboSize(0), + mMaxWidth(0), + mMaxHeight(0), + mWidthMM(0), + mHeightMM(0), + mDensity(-1), #ifdef USE_OPENGL mUseTextureSampler(true), mTextureSampler(0), @@ -246,28 +266,6 @@ void GraphicsManager::initGraphics(const bool noOpenGL A_UNUSED) #endif } -Graphics *GraphicsManager::createGraphics() -{ -#ifdef USE_OPENGL - switch (config.getIntValue("opengl")) - { - case 0: - return new Graphics; - case 1: - default: -#ifndef ANDROID - return new NormalOpenGLGraphics; - case 2: - return new SafeOpenGLGraphics; -#endif - case 3: - return new MobileOpenGLGraphics; - }; -#else - return new Graphics; -#endif -} - void GraphicsManager::setVideoMode() { const int bpp = 0; @@ -484,6 +482,7 @@ void GraphicsManager::updatePlanformExtensions() logger->log1(extensions2); } } + logger->log("width=%d", DisplayWidth(display, screenNum)); } #endif } @@ -992,3 +991,51 @@ void GraphicsManager::updateDebugLog() const } } #endif + +void GraphicsManager::detectPixelSize() +{ + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if (SDL_GetWMInfo(&info)) + { +#ifdef WIN32 + HDC hdc = GetDC(info.window); + if (hdc) + { +// SetProcessDPIAware(); + mMaxWidth = GetDeviceCaps(hdc, HORZRES); + mMaxHeight = GetDeviceCaps(hdc, VERTRES); + mWidthMM = GetDeviceCaps(hdc, HORZSIZE); + mHeightMM = GetDeviceCaps(hdc, VERTSIZE); + } +#elif defined USE_X11 + Display *const display = info.info.x11.display; + if (display) + { + Screen *const screen = XDefaultScreenOfDisplay(display); + if (!screen) + return; + + const int screenNum = XScreenNumberOfScreen(screen); + mMaxWidth = DisplayWidth(display, screenNum); + mMaxHeight = DisplayHeight(display, screenNum); + mWidthMM = DisplayWidthMM(display, screenNum); + mHeightMM = DisplayHeightMM(display, screenNum); + } +#endif + } +#if defined ANDROID + SDL_ANDROID_GetMetrics(&mMaxWidth, &mMaxHeight, + &mWidthMM, &mHeightMM, &mDensity); +#endif + logger->log("screen size in pixels: %dx%d", mMaxWidth, mMaxHeight); + logger->log("screen size in millimeters: %dx%d", mWidthMM, mHeightMM); + logger->log("screen density: %d", mDensity); +} + +std::string GraphicsManager::getDensityString() const +{ + if (mDensity >= 0 && mDensity < densitySize) + return densityNames[mDensity]; + return ""; +} |