summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-02-05 15:00:58 +0300
committerAndrei Karas <akaras@inbox.ru>2012-02-05 15:00:58 +0300
commit9a3a196dbf633a699c26d0227802a42f025c8bfd (patch)
treedfbdb2ff1e2c54d75a2bf6411d3f70df22518c28 /src/graphics.cpp
parentfc17ff22d9df50df9c5d1cf3dc0de358001271ed (diff)
parentece36a40d4e9a838cde01075d7681b8fc517b19f (diff)
downloadmanaplus-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.gz
manaplus-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.bz2
manaplus-9a3a196dbf633a699c26d0227802a42f025c8bfd.tar.xz
manaplus-9a3a196dbf633a699c26d0227802a42f025c8bfd.zip
Merge branch 'master' into stripped
Conflicts: src/guichan/gui.cpp src/guichan/include/guichan/sdl/sdlpixel.hpp
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp48
1 files changed, 44 insertions, 4 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index bbd398aa5..5848d8c14 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -47,13 +47,15 @@ Graphics::Graphics():
mBlitMode(BLIT_NORMAL),
mRedraw(false),
mDoubleBuffer(false),
- mSecure(false)
+ mSecure(false),
+ mOpenGL(0),
+ mEnableResize(false),
+ mNoFrame(false)
{
mRect.x = 0;
mRect.y = 0;
mRect.w = 0;
mRect.h = 0;
- mOpenGL = 0;
}
Graphics::~Graphics()
@@ -61,7 +63,8 @@ Graphics::~Graphics()
_endDraw();
}
-bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
+bool Graphics::setVideoMode(int w, int h, int bpp, bool fs,
+ bool hwaccel, bool resize, bool noFrame)
{
logger->log("Setting video mode %dx%d %s",
w, h, fs ? "fullscreen" : "windowed");
@@ -73,15 +76,22 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel)
mBpp = bpp;
mFullscreen = fs;
mHWAccel = hwaccel;
+ mEnableResize = resize;
+ mNoFrame = noFrame;
if (fs)
displayFlags |= SDL_FULLSCREEN;
+ else if (resize)
+ displayFlags |= SDL_RESIZABLE;
if (hwaccel)
displayFlags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
else
displayFlags |= SDL_SWSURFACE;
+ if (noFrame)
+ displayFlags |= SDL_NOFRAME;
+
setTarget(SDL_SetVideoMode(w, h, bpp, displayFlags));
if (!mTarget)
@@ -138,7 +148,37 @@ bool Graphics::setFullscreen(bool fs)
if (mFullscreen == fs)
return true;
- return setVideoMode(mWidth, mHeight, mBpp, fs, mHWAccel);
+ return setVideoMode(mWidth, mHeight, mBpp, fs, mHWAccel,
+ mEnableResize, mNoFrame);
+}
+
+bool Graphics::resizeScreen(int width, int height)
+{
+ if (mWidth == width && mHeight == height)
+ return true;
+
+ const int prevWidth = mWidth;
+ const int prevHeight = mHeight;
+
+ _endDraw();
+
+ bool success = setVideoMode(width, height, 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,
+ mFullscreen, mHWAccel, mEnableResize, mNoFrame))
+ {
+ return false;
+ }
+ }
+
+ _beginDraw();
+
+ return success;
}
int Graphics::getWidth() const