From c2351483dc7c918a592f2a1f52745c6552fb7d0c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 30 Jan 2012 17:03:58 +0300 Subject: Add option for enable/disable window resize. --- src/graphics.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/graphics.cpp') diff --git a/src/graphics.cpp b/src/graphics.cpp index 46433639e..30aece5dc 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -47,13 +47,14 @@ Graphics::Graphics(): mBlitMode(BLIT_NORMAL), mRedraw(false), mDoubleBuffer(false), - mSecure(false) + mSecure(false), + mOpenGL(0), + mEnableResize(false) { mRect.x = 0; mRect.y = 0; mRect.w = 0; mRect.h = 0; - mOpenGL = 0; } Graphics::~Graphics() @@ -61,7 +62,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) { logger->log("Setting video mode %dx%d %s", w, h, fs ? "fullscreen" : "windowed"); @@ -73,10 +75,11 @@ bool Graphics::setVideoMode(int w, int h, int bpp, bool fs, bool hwaccel) mBpp = bpp; mFullscreen = fs; mHWAccel = hwaccel; + mEnableResize = resize; if (fs) displayFlags |= SDL_FULLSCREEN; - else + else if (resize) displayFlags |= SDL_RESIZABLE; if (hwaccel) @@ -140,10 +143,10 @@ 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); } -bool Graphics::resize(int width, int height) +bool Graphics::resizeScreen(int width, int height) { if (mWidth == width && mHeight == height) return true; @@ -153,14 +156,18 @@ bool Graphics::resize(int width, int height) _endDraw(); - bool success = setVideoMode(width, height, mBpp, mFullscreen, mHWAccel); + bool success = setVideoMode(width, height, mBpp, + mFullscreen, mHWAccel, mEnableResize); // 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)) + if (!setVideoMode(prevWidth, prevHeight, mBpp, + mFullscreen, mHWAccel, mEnableResize)) + { return false; + } } _beginDraw(); -- cgit v1.2.3-60-g2f50