summaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-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
14 files changed, 144 insertions, 68 deletions
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,