summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-01-28 00:30:51 +0300
committerAndrei Karas <akaras@inbox.ru>2014-01-28 23:35:20 +0300
commita0b2deb4192bddad4d061f5d5df86411a437f01f (patch)
tree4739472959d83045eac4d7f7ddf3dc265d37b45c /src
parent226202ff807dc860991af0d6665ef9e9b48c1bed (diff)
downloadplus-a0b2deb4192bddad4d061f5d5df86411a437f01f.tar.gz
plus-a0b2deb4192bddad4d061f5d5df86411a437f01f.tar.bz2
plus-a0b2deb4192bddad4d061f5d5df86411a437f01f.tar.xz
plus-a0b2deb4192bddad4d061f5d5df86411a437f01f.zip
add support for screen scale in OpenGL modes.
Diffstat (limited to 'src')
-rw-r--r--src/client.cpp25
-rw-r--r--src/client.h4
-rw-r--r--src/defaults.cpp1
-rw-r--r--src/eventsmanager.cpp2
-rw-r--r--src/graphicsmanager.cpp15
-rw-r--r--src/gui/gui.cpp6
-rw-r--r--src/gui/sdlinput.cpp47
-rw-r--r--src/gui/widgets/tabs/setup_video.cpp32
-rw-r--r--src/render/graphics.cpp48
-rw-r--r--src/render/graphics.h29
-rw-r--r--src/render/mobileopenglgraphics.cpp28
-rw-r--r--src/render/normalopenglgraphics.cpp27
-rw-r--r--src/render/nullopenglgraphics.cpp9
-rw-r--r--src/render/openglgraphicsdef.hpp4
-rw-r--r--src/render/safeopenglgraphics.cpp28
-rw-r--r--src/render/sdl2graphics.cpp14
-rw-r--r--src/render/sdl2graphics.h1
-rw-r--r--src/render/sdl2softwaregraphics.cpp9
-rw-r--r--src/render/sdl2softwaregraphics.h1
-rw-r--r--src/render/sdlgraphics.cpp12
-rw-r--r--src/render/sdlgraphics.h1
-rw-r--r--src/render/surfacegraphics.h1
22 files changed, 231 insertions, 113 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 13835c938..82652e433 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -2798,25 +2798,30 @@ bool Client::isTmw() const
return false;
}
-void Client::resizeVideo(int width, int height, const bool always)
+void Client::resizeVideo(int actualWidth,
+ int actualHeight,
+ const bool always)
{
// Keep a minimum size. This isn't adhered to by the actual window, but
// it keeps some window positions from getting messed up.
- width = std::max(470, width);
- height = std::max(320, height);
+ actualWidth = std::max(470, actualWidth);
+ actualHeight = std::max(320, actualHeight);
if (!mainGraphics)
return;
- if (!always && mainGraphics->mWidth == width
- && mainGraphics->mHeight == height)
+ if (!always
+ && mainGraphics->mActualWidth == actualWidth
+ && mainGraphics->mActualHeight == actualHeight)
{
return;
}
- touchManager.resize(width, height);
-
- if (mainGraphics->resizeScreen(width, height))
+ if (mainGraphics->resizeScreen(actualWidth, actualHeight))
{
+ const int width = mainGraphics->mWidth;
+ const int height = mainGraphics->mHeight;
+ touchManager.resize(width, height);
+
if (gui)
gui->videoResized();
@@ -2852,8 +2857,8 @@ void Client::resizeVideo(int width, int height, const bool always)
if (gui)
gui->draw();
- config.setValue("screenwidth", width);
- config.setValue("screenheight", height);
+ config.setValue("screenwidth", actualWidth);
+ config.setValue("screenheight", actualHeight);
}
}
diff --git a/src/client.h b/src/client.h
index 7a88c6734..82bb4be15 100644
--- a/src/client.h
+++ b/src/client.h
@@ -311,7 +311,9 @@ public:
void writePacketLimits(const std::string &packetLimitsName) const;
- void resizeVideo(int width, int height, const bool always = false);
+ void resizeVideo(int actualWidth,
+ int actualHeight,
+ const bool always);
bool limitPackets(const int type) A_WARN_UNUSED;
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 9362473fd..4e8a2246a 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -356,6 +356,7 @@ DefaultsData* getConfigDefaults()
AddDEF("showmotd", false);
AddDEF("playMapAnimations", true);
AddDEF("usepets", true);
+ AddDEF("scale", 1);
return configData;
}
diff --git a/src/eventsmanager.cpp b/src/eventsmanager.cpp
index 6c102bdc1..237e7bf68 100644
--- a/src/eventsmanager.cpp
+++ b/src/eventsmanager.cpp
@@ -77,7 +77,7 @@ bool EventsManager::handleCommonEvents(const SDL_Event &event)
return true;
#else
case SDL_VIDEORESIZE:
- client->resizeVideo(event.resize.w, event.resize.h);
+ client->resizeVideo(event.resize.w, event.resize.h, false);
return true;
case SDL_ACTIVEEVENT:
handleActive(event);
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index 552f5a018..0a7f78eb6 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -377,8 +377,19 @@ void GraphicsManager::setVideoMode()
int height = config.getIntValue("screenheight");
#endif
+ int scale = 1;
+ if (mainGraphics->allowScale())
+ {
+ if (!scale)
+ scale = 1;
+ scale = config.getIntValue("scale");
+ if (width / scale < 470 || height / scale < 320)
+ scale = 1;
+ logger->log("set scale: %d", scale);
+ }
+
// Try to set the desired video mode
- if (!mainGraphics->setVideoMode(width, height, bpp,
+ if (!mainGraphics->setVideoMode(width, height, scale, bpp,
fullscreen, hwaccel, enableResize, noFrame))
{
logger->log(strprintf("Couldn't set %dx%dx%d video mode: %s",
@@ -396,7 +407,7 @@ void GraphicsManager::setVideoMode()
config.setValueInt("screenwidth", oldWidth);
config.setValueInt("screenheight", oldHeight);
config.setValue("screen", oldFullscreen == 1);
- if (!mainGraphics->setVideoMode(oldWidth, oldHeight, bpp,
+ if (!mainGraphics->setVideoMode(oldWidth, oldHeight, scale, bpp,
oldFullscreen, hwaccel, enableResize, noFrame))
{
logger->safeError(strprintf("Couldn't restore %dx%dx%d "
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index d016c0aa3..dcd4d82ea 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -942,5 +942,9 @@ void Gui::removeDragged(gcn::Widget *widget)
uint32_t Gui::getMouseState(int *const x, int *const y) const
{
- return SDL_GetMouseState(x, y);
+ const uint32_t res = SDL_GetMouseState(x, y);
+ const int scale = mainGraphics->getScale();
+ (*x) /= scale;
+ (*y) /= scale;
+ return res;
}
diff --git a/src/gui/sdlinput.cpp b/src/gui/sdlinput.cpp
index 653806491..193a35dfe 100644
--- a/src/gui/sdlinput.cpp
+++ b/src/gui/sdlinput.cpp
@@ -81,6 +81,8 @@
#include "input/inputmanager.h"
+#include "render/graphics.h"
+
#ifdef USE_SDL2
#include "gui/gui.h"
#endif
@@ -210,14 +212,19 @@ void SDLInput::pushInput(const SDL_Event &event)
#endif
case SDL_MOUSEBUTTONDOWN:
+ {
mMouseDown = true;
- mouseInput.setX(event.button.x);
- mouseInput.setY(event.button.y);
+ const int scale = mainGraphics->getScale();
+ const int x = event.button.x / scale;
+ const int y = event.button.y / scale;
+ mouseInput.setX(x);
+ mouseInput.setY(y);
#ifdef ANDROID
#ifdef USE_SDL2
- mouseInput.setReal(event.button.x, event.button.y);
+ mouseInput.setReal(x, y);
#else
- mouseInput.setReal(event.button.realx, event.button.realy);
+ mouseInput.setReal(event.button.realx / scale,
+ event.button.realy / scale);
#endif
#endif
mouseInput.setButton(convertMouseButton(event.button.button));
@@ -233,16 +240,21 @@ void SDLInput::pushInput(const SDL_Event &event)
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
-
+ }
case SDL_MOUSEBUTTONUP:
+ {
mMouseDown = false;
- mouseInput.setX(event.button.x);
- mouseInput.setY(event.button.y);
+ const int scale = mainGraphics->getScale();
+ const int x = event.button.x / scale;
+ const int y = event.button.y / scale;
+ mouseInput.setX(x);
+ mouseInput.setY(y);
#ifdef ANDROID
#ifdef USE_SDL2
- mouseInput.setReal(event.button.x, event.button.y);
+ mouseInput.setReal(x, y);
#else
- mouseInput.setReal(event.button.realx, event.button.realy);
+ mouseInput.setReal(event.button.realx / scale,
+ event.button.realy / scale);
#endif
#endif
mouseInput.setButton(convertMouseButton(event.button.button));
@@ -250,15 +262,20 @@ void SDLInput::pushInput(const SDL_Event &event)
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
-
+ }
case SDL_MOUSEMOTION:
- mouseInput.setX(event.motion.x);
- mouseInput.setY(event.motion.y);
+ {
+ const int scale = mainGraphics->getScale();
+ const int x = event.motion.x / scale;
+ const int y = event.motion.y / scale;
+ mouseInput.setX(x);
+ mouseInput.setY(y);
#ifdef ANDROID
#ifdef USE_SDL2
- mouseInput.setReal(event.motion.x, event.motion.y);
+ mouseInput.setReal(x, y);
#else
- mouseInput.setReal(event.motion.realx, event.motion.realy);
+ mouseInput.setReal(event.motion.realx / scale,
+ event.motion.realy / scale);
#endif
#endif
mouseInput.setButton(gcn::MouseInput::EMPTY);
@@ -266,7 +283,7 @@ void SDLInput::pushInput(const SDL_Event &event)
mouseInput.setTimeStamp(SDL_GetTicks());
mMouseInputQueue.push(mouseInput);
break;
-
+ }
#ifndef USE_SDL2
case SDL_ACTIVEEVENT:
/*
diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp
index feebb774a..c977318e6 100644
--- a/src/gui/widgets/tabs/setup_video.cpp
+++ b/src/gui/widgets/tabs/setup_video.cpp
@@ -122,8 +122,8 @@ ModeListModel::ModeListModel() :
addCustomMode("1280x1024");
addCustomMode("1400x900");
addCustomMode("1500x990");
- addCustomMode(toString(mainGraphics->mWidth).append("x")
- .append(toString(mainGraphics->mHeight)));
+ addCustomMode(toString(mainGraphics->mActualWidth).append("x")
+ .append(toString(mainGraphics->mActualHeight)));
std::sort(mVideoModes.begin(), mVideoModes.end(), &modeSorter);
mVideoModes.push_back("custom");
@@ -243,8 +243,9 @@ Setup_Video::Setup_Video(const Widget2 *const widget) :
mFpsCheckBox->setSelected(mFps > 0);
// Pre-select the current video mode.
- const std::string videoMode = toString(mainGraphics->mWidth).append("x")
- .append(toString(mainGraphics->mHeight));
+ const std::string videoMode = toString(
+ mainGraphics->mActualWidth).append("x").append(
+ toString(mainGraphics->mActualHeight));
mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
mModeList->setActionEventId("videomode");
@@ -428,11 +429,11 @@ void Setup_Video::cancel()
config.setValue("screen", mFullScreenEnabled);
// Set back to the current video mode.
- std::string videoMode = toString(mainGraphics->mWidth).append("x")
- .append(toString(mainGraphics->mHeight));
+ std::string videoMode = toString(mainGraphics->mActualWidth).append("x")
+ .append(toString(mainGraphics->mActualHeight));
mModeList->setSelected(mModeListModel->getIndexOf(videoMode));
- config.setValue("screenwidth", mainGraphics->mWidth);
- config.setValue("screenheight", mainGraphics->mHeight);
+ config.setValue("screenwidth", mainGraphics->mActualWidth);
+ config.setValue("screenheight", mainGraphics->mActualHeight);
config.setValue("customcursor", mCustomCursorEnabled);
config.setValue("opengl", static_cast<int>(mOpenGLEnabled));
@@ -474,18 +475,19 @@ void Setup_Video::action(const gcn::ActionEvent &event)
if (!width || !height)
return;
- if (width != mainGraphics->mWidth || height != mainGraphics->mHeight)
+ if (width != mainGraphics->mActualWidth
+ || height != mainGraphics->mActualHeight)
{
#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID)
if (intToRenderType(config.getIntValue("opengl"))
== RENDER_SOFTWARE)
{
- client->resizeVideo(width, height);
+ client->resizeVideo(width, height, false);
}
else
{
- if (width < mainGraphics->mWidth
- || height < mainGraphics->mHeight)
+ if (width < mainGraphics->mActualWidth
+ || height < mainGraphics->mActualHeight)
{
// TRANSLATORS: video settings warning
new OkDialog(_("Screen Resolution Changed"),
@@ -505,13 +507,13 @@ void Setup_Video::action(const gcn::ActionEvent &event)
}
#else
mainGraphics->setWindowSize(width, height);
- client->resizeVideo(width, height);
+ client->resizeVideo(width, height, false);
#endif
}
config.setValue("oldscreen", config.getBoolValue("screen"));
- config.setValue("oldscreenwidth", mainGraphics->mWidth);
- config.setValue("oldscreenheight", mainGraphics->mHeight);
+ config.setValue("oldscreenwidth", mainGraphics->mActualWidth);
+ config.setValue("oldscreenheight", mainGraphics->mActualHeight);
config.setValue("screenwidth", width);
config.setValue("screenheight", height);
}
diff --git a/src/render/graphics.cpp b/src/render/graphics.cpp
index c88892cc4..27682f1f0 100644
--- a/src/render/graphics.cpp
+++ b/src/render/graphics.cpp
@@ -51,6 +51,8 @@ Graphics::Graphics() :
gcn::Graphics(),
mWidth(0),
mHeight(0),
+ mActualWidth(0),
+ mActualHeight(0),
mWindow(nullptr),
#ifdef USE_SDL2
mRenderer(nullptr),
@@ -72,6 +74,7 @@ Graphics::Graphics() :
mName("Unknown"),
mStartFreeMem(0),
mSync(false),
+ mScale(1),
mColor(),
mColor2()
{
@@ -105,21 +108,28 @@ void Graphics::setSync(const bool sync)
mSync = sync;
}
-void Graphics::setMainFlags(const int w, const int h, const int bpp,
- const bool fs, const bool hwaccel,
- const bool resize, const bool noFrame)
+void Graphics::setMainFlags(const int w, const int h,
+ const int scale,
+ const int bpp,
+ const bool fs,
+ const bool hwaccel,
+ const bool resize,
+ const bool noFrame)
{
logger->log("graphics backend: %s", getName().c_str());
logger->log("Setting video mode %dx%d %s",
w, h, fs ? "fullscreen" : "windowed");
- mWidth = w;
- mHeight = h;
+ mWidth = w / scale;
+ mHeight = h / scale;
mBpp = bpp;
mFullscreen = fs;
mHWAccel = hwaccel;
mEnableResize = resize;
mNoFrame = noFrame;
+ mScale = scale;
+ mActualWidth = w;
+ mActualHeight = h;
}
int Graphics::getOpenGLFlags() const
@@ -161,7 +171,8 @@ bool Graphics::setOpenGLMode()
{
#ifdef USE_OPENGL
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
- if (!(mWindow = graphicsManager.createWindow(mWidth, mHeight,
+ if (!(mWindow = graphicsManager.createWindow(
+ mActualWidth, mActualHeight,
mBpp, getOpenGLFlags())))
{
mRect.w = 0;
@@ -173,15 +184,16 @@ bool Graphics::setOpenGLMode()
int w1 = 0;
int h1 = 0;
SDL_GetWindowSize(mWindow, &w1, &h1);
- mRect.w = w1;
- mRect.h = h1;
+ mRect.w = w1 / mScale;
+ mRect.h = h1 / mScale;
mGLContext = SDL_GL_CreateContext(mWindow);
#else // USE_SDL2
- mRect.w = static_cast<uint16_t>(mWindow->w);
- mRect.h = static_cast<uint16_t>(mWindow->h);
+ mRect.w = static_cast<uint16_t>(mWindow->w / mScale);
+ mRect.h = static_cast<uint16_t>(mWindow->h / mScale);
+
#endif // USE_SDL2
#ifdef __APPLE__
@@ -196,7 +208,7 @@ bool Graphics::setOpenGLMode()
graphicsManager.logVersion();
// Setup OpenGL
- glViewport(0, 0, mWidth, mHeight);
+ glViewport(0, 0, mActualWidth, mActualHeight);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
int gotDoubleBuffer = 0;
SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &gotDoubleBuffer);
@@ -374,7 +386,7 @@ bool Graphics::setFullscreen(const bool fs)
if (mFullscreen == fs)
return true;
- return setVideoMode(mWidth, mHeight, mBpp, fs, mHWAccel,
+ return setVideoMode(mActualWidth, mActualHeight, mScale, mBpp, fs, mHWAccel,
mEnableResize, mNoFrame);
}
@@ -386,10 +398,10 @@ bool Graphics::resizeScreen(const int width, const int height)
#ifdef USE_SDL2
_endDraw();
- mRect.w = width;
- mRect.h = height;
- mWidth = width;
- mHeight = height;
+ mRect.w = width / mScale;
+ mRect.h = height / mScale;
+ mWidth = width / mScale;
+ mHeight = height / mScale;
#ifdef USE_OPENGL
// +++ probably this way will not work in windows/mac
@@ -409,14 +421,14 @@ bool Graphics::resizeScreen(const int width, const int height)
_endDraw();
- const bool success = setVideoMode(width, height, mBpp,
+ const bool success = setVideoMode(width, height, mScale, mBpp,
mFullscreen, mHWAccel, mEnableResize, mNoFrame);
// If it didn't work, try to restore the previous size. If that didn't
// work either, bail out (but then we're in deep trouble).
if (!success)
{
- if (!setVideoMode(prevWidth, prevHeight, mBpp,
+ if (!setVideoMode(prevWidth, prevHeight, mScale, mBpp,
mFullscreen, mHWAccel, mEnableResize, mNoFrame))
{
return false;
diff --git a/src/render/graphics.h b/src/render/graphics.h
index 82ef32fea..adf1b97c4 100644
--- a/src/render/graphics.h
+++ b/src/render/graphics.h
@@ -127,9 +127,13 @@ class Graphics : public gcn::Graphics
/**
* Try to create a window with the given settings.
*/
- virtual bool setVideoMode(const int w, const int h, const int bpp,
- const bool fs, const bool hwaccel,
- const bool resize, const bool noFrame) = 0;
+ virtual bool setVideoMode(const int w, const int h,
+ const int scale,
+ const int bpp,
+ const bool fs,
+ const bool hwaccel,
+ const bool resize,
+ const bool noFrame) = 0;
/**
* Set fullscreen mode.
@@ -341,8 +345,16 @@ class Graphics : public gcn::Graphics
virtual void completeCache() = 0;
+ int getScale() const
+ { return mScale; }
+
+ virtual bool allowScale() const
+ { return false; }
+
int mWidth;
int mHeight;
+ int mActualWidth;
+ int mActualHeight;
protected:
/**
@@ -350,9 +362,13 @@ class Graphics : public gcn::Graphics
*/
Graphics();
- void setMainFlags(const int w, const int h, const int bpp,
- const bool fs, const bool hwaccel,
- const bool resize, const bool noFrame);
+ void setMainFlags(const int w, const int h,
+ const int scale,
+ const int bpp,
+ const bool fs,
+ const bool hwaccel,
+ const bool resize,
+ const bool noFrame);
int getOpenGLFlags() const A_WARN_UNUSED;
@@ -386,6 +402,7 @@ class Graphics : public gcn::Graphics
std::string mName;
int mStartFreeMem;
bool mSync;
+ int mScale;
gcn::Color mColor;
gcn::Color mColor2;
};
diff --git a/src/render/mobileopenglgraphics.cpp b/src/render/mobileopenglgraphics.cpp
index d273e9f65..82bf04dc8 100644
--- a/src/render/mobileopenglgraphics.cpp
+++ b/src/render/mobileopenglgraphics.cpp
@@ -120,11 +120,14 @@ void MobileOpenGLGraphics::initArrays()
}
bool MobileOpenGLGraphics::setVideoMode(const int w, const int h,
- const int bpp, const bool fs,
- const bool hwaccel, const bool resize,
+ const int scale,
+ const int bpp,
+ const bool fs,
+ const bool hwaccel,
+ const bool resize,
const bool noFrame)
{
- setMainFlags(w, h, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
return setOpenGLMode();
}
@@ -842,10 +845,12 @@ void MobileOpenGLGraphics::_beginDraw()
#ifdef ANDROID
glOrthof(0.0, static_cast<float>(mRect.w),
- static_cast<float>(mRect.h), 0.0, -1.0, 1.0);
+ static_cast<float>(mRect.h),
+ 0.0, -1.0, 1.0);
#else
glOrtho(0.0, static_cast<double>(mRect.w),
- static_cast<double>(mRect.h), 0.0, -1.0, 1.0);
+ static_cast<double>(mRect.h),
+ 0.0, -1.0, 1.0);
#endif
glMatrixMode(GL_MODELVIEW);
@@ -969,9 +974,10 @@ bool MobileOpenGLGraphics::pushClipArea(gcn::Rectangle area)
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
}
- glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
- clipArea.width, clipArea.height);
-
+ glScissor(clipArea.x * mScale,
+ (mRect.h - clipArea.y - clipArea.height) * mScale,
+ clipArea.width * mScale,
+ clipArea.height * mScale);
return result;
}
@@ -997,8 +1003,10 @@ void MobileOpenGLGraphics::popClipArea()
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
}
- glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
- clipArea.width, clipArea.height);
+ glScissor(clipArea.x * mScale,
+ (mRect.h - clipArea.y - clipArea.height) * mScale,
+ clipArea.width * mScale,
+ clipArea.height * mScale);
}
#ifdef ANDROID
diff --git a/src/render/normalopenglgraphics.cpp b/src/render/normalopenglgraphics.cpp
index 5b7abd895..e8e1a2116 100644
--- a/src/render/normalopenglgraphics.cpp
+++ b/src/render/normalopenglgraphics.cpp
@@ -140,11 +140,14 @@ void NormalOpenGLGraphics::initArrays()
}
bool NormalOpenGLGraphics::setVideoMode(const int w, const int h,
- const int bpp, const bool fs,
- const bool hwaccel, const bool resize,
+ const int scale,
+ const int bpp,
+ const bool fs,
+ const bool hwaccel,
+ const bool resize,
const bool noFrame)
{
- setMainFlags(w, h, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
return setOpenGLMode();
}
@@ -1103,10 +1106,12 @@ void NormalOpenGLGraphics::_beginDraw()
const int h = mRect.h;
#ifdef ANDROID
- glOrthof(0.0, static_cast<float>(w), static_cast<float>(h),
+ glOrthof(0.0, static_cast<float>(w),
+ static_cast<float>(h),
0.0, -1.0, 1.0);
#else
- glOrtho(0.0, static_cast<double>(w), static_cast<double>(h),
+ glOrtho(0.0, static_cast<double>(w),
+ static_cast<double>(h),
0.0, -1.0, 1.0);
#endif
@@ -1229,8 +1234,10 @@ bool NormalOpenGLGraphics::pushClipArea(gcn::Rectangle area)
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
}
- glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
- clipArea.width, clipArea.height);
+ glScissor(clipArea.x * mScale,
+ (mRect.h - clipArea.y - clipArea.height) * mScale,
+ clipArea.width * mScale,
+ clipArea.height * mScale);
return result;
}
@@ -1257,8 +1264,10 @@ void NormalOpenGLGraphics::popClipArea()
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
}
- glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
- clipArea.width, clipArea.height);
+ glScissor(clipArea.x * mScale,
+ (mRect.h - clipArea.y - clipArea.height) * mScale,
+ clipArea.width * mScale,
+ clipArea.height * mScale);
}
void NormalOpenGLGraphics::drawPoint(int x, int y)
diff --git a/src/render/nullopenglgraphics.cpp b/src/render/nullopenglgraphics.cpp
index 2f1a59976..3ea1e4182 100644
--- a/src/render/nullopenglgraphics.cpp
+++ b/src/render/nullopenglgraphics.cpp
@@ -83,11 +83,14 @@ void NullOpenGLGraphics::initArrays()
}
bool NullOpenGLGraphics::setVideoMode(const int w, const int h,
- const int bpp, const bool fs,
- const bool hwaccel, const bool resize,
+ const int scale,
+ const int bpp,
+ const bool fs,
+ const bool hwaccel,
+ const bool resize,
const bool noFrame)
{
- setMainFlags(w, h, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
return setOpenGLMode();
}
diff --git a/src/render/openglgraphicsdef.hpp b/src/render/openglgraphicsdef.hpp
index 9f6d9d319..6654254cb 100644
--- a/src/render/openglgraphicsdef.hpp
+++ b/src/render/openglgraphicsdef.hpp
@@ -21,6 +21,7 @@
*/
bool setVideoMode(const int w, const int h,
+ const int scalle,
const int bpp,
const bool fs,
const bool hwaccel,
@@ -141,6 +142,9 @@
void completeCache() override final;
+ bool allowScale() const override final
+ { return true; }
+
static void bindTexture(const GLenum target, const GLuint texture);
static GLuint mLastImage;
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index c6e8c1f30..bf9334655 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -53,11 +53,15 @@ SafeOpenGLGraphics::~SafeOpenGLGraphics()
{
}
-bool SafeOpenGLGraphics::setVideoMode(const int w, const int h, const int bpp,
- const bool fs, const bool hwaccel,
- const bool resize, const bool noFrame)
+bool SafeOpenGLGraphics::setVideoMode(const int w, const int h,
+ const int scale,
+ const int bpp,
+ const bool fs,
+ const bool hwaccel,
+ const bool resize,
+ const bool noFrame)
{
- setMainFlags(w, h, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
return setOpenGLMode();
}
@@ -436,7 +440,8 @@ void SafeOpenGLGraphics::_beginDraw()
glLoadIdentity();
glOrtho(0.0, static_cast<double>(mRect.w),
- static_cast<double>(mRect.h), 0.0, -1.0, 1.0);
+ static_cast<double>(mRect.h),
+ 0.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -537,9 +542,10 @@ bool SafeOpenGLGraphics::pushClipArea(gcn::Rectangle area)
glPushMatrix();
glTranslatef(static_cast<GLfloat>(transX + clipArea.xOffset),
static_cast<GLfloat>(transY + clipArea.yOffset), 0);
- glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
- clipArea.width, clipArea.height);
-
+ glScissor(clipArea.x * mScale,
+ (mRect.h - clipArea.y - clipArea.height) * mScale,
+ clipArea.width * mScale,
+ clipArea.height * mScale);
return result;
}
@@ -552,8 +558,10 @@ void SafeOpenGLGraphics::popClipArea()
glPopMatrix();
const gcn::ClipRectangle &clipArea = mClipStack.top();
- glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
- clipArea.width, clipArea.height);
+ glScissor(clipArea.x * mScale,
+ (mRect.h - clipArea.y - clipArea.height) * mScale,
+ clipArea.width * mScale,
+ clipArea.height * mScale);
}
void SafeOpenGLGraphics::drawPoint(int x, int y)
diff --git a/src/render/sdl2graphics.cpp b/src/render/sdl2graphics.cpp
index 96e05c8f6..97f231d08 100644
--- a/src/render/sdl2graphics.cpp
+++ b/src/render/sdl2graphics.cpp
@@ -718,11 +718,15 @@ void SDLGraphics::drawLine(int x1, int y1, int x2, int y2)
SDL_RenderDrawLines(mRenderer, points, 2);
}
-bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp,
- const bool fs, const bool hwaccel,
- const bool resize, const bool noFrame)
-{
- setMainFlags(w, h, bpp, fs, hwaccel, resize, noFrame);
+bool SDLGraphics::setVideoMode(const int w, const int h,
+ const int scale,
+ const int bpp,
+ const bool fs,
+ const bool hwaccel,
+ const bool resize,
+ const bool noFrame)
+{
+ setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
getSoftwareFlags())))
diff --git a/src/render/sdl2graphics.h b/src/render/sdl2graphics.h
index 5f1e8ac1c..c4e0d74a7 100644
--- a/src/render/sdl2graphics.h
+++ b/src/render/sdl2graphics.h
@@ -129,6 +129,7 @@ class SDLGraphics final : public Graphics
void drawLine(int x1, int y1, int x2, int y2) override final;
bool setVideoMode(const int w, const int h,
+ const int scale,
const int bpp,
const bool fs,
const bool hwaccel,
diff --git a/src/render/sdl2softwaregraphics.cpp b/src/render/sdl2softwaregraphics.cpp
index 95c8f08b1..088aba98c 100644
--- a/src/render/sdl2softwaregraphics.cpp
+++ b/src/render/sdl2softwaregraphics.cpp
@@ -1468,11 +1468,14 @@ void SDL2SoftwareGraphics::drawLine(int x1, int y1, int x2, int y2)
}
bool SDL2SoftwareGraphics::setVideoMode(const int w, const int h,
- const int bpp, const bool fs,
- const bool hwaccel, const bool resize,
+ const int scale,
+ const int bpp,
+ const bool fs,
+ const bool hwaccel,
+ const bool resize,
const bool noFrame)
{
- setMainFlags(w, h, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
getSoftwareFlags())))
diff --git a/src/render/sdl2softwaregraphics.h b/src/render/sdl2softwaregraphics.h
index 295118067..3ac6cb212 100644
--- a/src/render/sdl2softwaregraphics.h
+++ b/src/render/sdl2softwaregraphics.h
@@ -129,6 +129,7 @@ class SDL2SoftwareGraphics final : public Graphics
void drawLine(int x1, int y1, int x2, int y2) override final;
bool setVideoMode(const int w, const int h,
+ const int scale,
const int bpp,
const bool fs,
const bool hwaccel,
diff --git a/src/render/sdlgraphics.cpp b/src/render/sdlgraphics.cpp
index 964f2d25a..e0e22cac9 100644
--- a/src/render/sdlgraphics.cpp
+++ b/src/render/sdlgraphics.cpp
@@ -1465,11 +1465,15 @@ void SDLGraphics::drawLine(int x1, int y1, int x2, int y2)
// other cases not implimented
}
-bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp,
- const bool fs, const bool hwaccel,
- const bool resize, const bool noFrame)
+bool SDLGraphics::setVideoMode(const int w, const int h,
+ const int scale,
+ const int bpp,
+ const bool fs,
+ const bool hwaccel,
+ const bool resize,
+ const bool noFrame)
{
- setMainFlags(w, h, bpp, fs, hwaccel, resize, noFrame);
+ setMainFlags(w, h, scale, bpp, fs, hwaccel, resize, noFrame);
if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
getSoftwareFlags())))
diff --git a/src/render/sdlgraphics.h b/src/render/sdlgraphics.h
index 53a139612..17b54db92 100644
--- a/src/render/sdlgraphics.h
+++ b/src/render/sdlgraphics.h
@@ -129,6 +129,7 @@ class SDLGraphics final : public Graphics
void drawLine(int x1, int y1, int x2, int y2) override final;
bool setVideoMode(const int w, const int h,
+ const int scale,
const int bpp,
const bool fs,
const bool hwaccel,
diff --git a/src/render/surfacegraphics.h b/src/render/surfacegraphics.h
index 3b0c639da..c3e6cb2ee 100644
--- a/src/render/surfacegraphics.h
+++ b/src/render/surfacegraphics.h
@@ -172,6 +172,7 @@ class SurfaceGraphics final : public Graphics
{ }
bool setVideoMode(const int w A_UNUSED, const int h A_UNUSED,
+ const int scale A_UNUSED,
const int bpp A_UNUSED,
const bool fs A_UNUSED, const bool hwaccel A_UNUSED,
const bool resize A_UNUSED,