diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-01-29 00:55:06 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-01-29 00:55:06 +0300 |
commit | dbc30204cae020ff0be41fb8f20bbb3a531686b3 (patch) | |
tree | 844ffa7b47c576ca93631020665a92af08603c25 /src/render | |
parent | b9b358dc0d5c268a923c3a961ac8c072ccc691cf (diff) | |
download | plus-dbc30204cae020ff0be41fb8f20bbb3a531686b3.tar.gz plus-dbc30204cae020ff0be41fb8f20bbb3a531686b3.tar.bz2 plus-dbc30204cae020ff0be41fb8f20bbb3a531686b3.tar.xz plus-dbc30204cae020ff0be41fb8f20bbb3a531686b3.zip |
allow apply scale without client restart.
Diffstat (limited to 'src/render')
-rw-r--r-- | src/render/graphics.cpp | 25 | ||||
-rw-r--r-- | src/render/graphics.h | 4 | ||||
-rw-r--r-- | src/render/openglgraphicsdef.hpp | 2 |
3 files changed, 26 insertions, 5 deletions
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp index 27682f1f0..82f44460b 100644 --- a/src/render/graphics.cpp +++ b/src/render/graphics.cpp @@ -120,16 +120,35 @@ void Graphics::setMainFlags(const int w, const int h, logger->log("Setting video mode %dx%d %s", w, h, fs ? "fullscreen" : "windowed"); - mWidth = w / scale; - mHeight = h / scale; mBpp = bpp; mFullscreen = fs; mHWAccel = hwaccel; mEnableResize = resize; mNoFrame = noFrame; - mScale = scale; mActualWidth = w; mActualHeight = h; + setScale(scale); +} + +void Graphics::setScale(int scale) +{ + if (isAllowScale()) + { + if (!scale) + scale = 1; + if (mActualWidth / scale < 470 || mActualHeight / scale < 320) + scale = 1; + logger->log("set scale: %d", scale); + mScale = scale; + } + else + { + mScale = 1; + } + mWidth = mActualWidth / mScale; + mHeight = mActualHeight / mScale; + mRect.w = mWidth; + mRect.h = mHeight; } int Graphics::getOpenGLFlags() const diff --git a/src/render/graphics.h b/src/render/graphics.h index adf1b97c4..0cb510195 100644 --- a/src/render/graphics.h +++ b/src/render/graphics.h @@ -348,9 +348,11 @@ class Graphics : public gcn::Graphics int getScale() const { return mScale; } - virtual bool allowScale() const + virtual bool isAllowScale() const { return false; } + void setScale(int scale); + int mWidth; int mHeight; int mActualWidth; diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp index 6654254cb..89f8e63a9 100644 --- a/src/render/openglgraphicsdef.hpp +++ b/src/render/openglgraphicsdef.hpp @@ -142,7 +142,7 @@ void completeCache() override final; - bool allowScale() const override final + bool isAllowScale() const override final { return true; } static void bindTexture(const GLenum target, const GLuint texture); |