From dbc30204cae020ff0be41fb8f20bbb3a531686b3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Jan 2014 00:55:06 +0300 Subject: allow apply scale without client restart. --- src/render/graphics.cpp | 25 ++++++++++++++++++++++--- src/render/graphics.h | 4 +++- src/render/openglgraphicsdef.hpp | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-) (limited to 'src/render') 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); -- cgit v1.2.3-70-g09d2