summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-22 11:59:38 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:15 +0300
commit2480ea4cc668ff99007dd6fb8b44911eea5d5287 (patch)
treec8fc22a9612d30474cddd6d40da5269ffd7f55a5
parent07390a4c8dcde85602c1a91d3773061d67d169ab (diff)
downloadplus-2480ea4cc668ff99007dd6fb8b44911eea5d5287.tar.gz
plus-2480ea4cc668ff99007dd6fb8b44911eea5d5287.tar.bz2
plus-2480ea4cc668ff99007dd6fb8b44911eea5d5287.tar.xz
plus-2480ea4cc668ff99007dd6fb8b44911eea5d5287.zip
store window size into rectangle.
-rw-r--r--src/compoundsprite.cpp2
-rw-r--r--src/graphics.cpp5
-rw-r--r--src/graphics.h9
-rw-r--r--src/mobileopenglgraphics.cpp20
-rw-r--r--src/normalopenglgraphics.cpp23
-rw-r--r--src/resources/atlasmanager.cpp6
-rw-r--r--src/safeopenglgraphics.cpp16
-rw-r--r--src/sdl2graphics.cpp6
-rw-r--r--src/sdlgraphics.cpp6
9 files changed, 56 insertions, 37 deletions
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index b65d238d4..24e8306c3 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -338,7 +338,7 @@ void CompoundSprite::redraw() const
SDLGraphics *graphics = new SDLGraphics();
graphics->setBlitMode(SDLGraphics::BLIT_GFX);
- graphics->setWindow(surface);
+ graphics->setWindow(surface, BUFFER_WIDTH, BUFFER_HEIGHT);
graphics->_beginDraw();
int tileX = 32 / 2;
diff --git a/src/graphics.cpp b/src/graphics.cpp
index ac219bc9a..d1d5a9590 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -148,9 +148,14 @@ bool Graphics::setOpenGLMode()
if (!(mWindow = graphicsManager.createWindow(mWidth, mHeight,
mBpp, getOpenGLFlags())))
{
+ mRect.w = 0;
+ mRect.h = 0;
return false;
}
+ mRect.w = static_cast<uint16_t>(mWindow->w);
+ mRect.h = static_cast<uint16_t>(mWindow->h);
+
#ifdef __APPLE__
if (mSync)
{
diff --git a/src/graphics.h b/src/graphics.h
index cdd5b2e71..04234d415 100644
--- a/src/graphics.h
+++ b/src/graphics.h
@@ -105,8 +105,13 @@ class Graphics : public gcn::Graphics
*/
virtual ~Graphics();
- void setWindow(SDL_Window *const window)
- { mWindow = window; }
+ void setWindow(SDL_Window *const window,
+ const int width, const int height)
+ {
+ mWindow = window;
+ mRect.w = width;
+ mRect.h = height;
+ }
SDL_Window *getWindow() const
{ return mWindow; }
diff --git a/src/mobileopenglgraphics.cpp b/src/mobileopenglgraphics.cpp
index 2aec87498..e2991eddc 100644
--- a/src/mobileopenglgraphics.cpp
+++ b/src/mobileopenglgraphics.cpp
@@ -845,11 +845,11 @@ void MobileOpenGLGraphics::_beginDraw()
glLoadIdentity();
#ifdef ANDROID
- glOrthof(0.0, static_cast<float>(mWindow->w),
- static_cast<float>(mWindow->h), 0.0, -1.0, 1.0);
+ glOrthof(0.0, static_cast<float>(mRect.w),
+ static_cast<float>(mRect.h), 0.0, -1.0, 1.0);
#else
- glOrtho(0.0, static_cast<double>(mWindow->w),
- static_cast<double>(mWindow->h), 0.0, -1.0, 1.0);
+ glOrtho(0.0, static_cast<double>(mRect.w),
+ static_cast<double>(mRect.h), 0.0, -1.0, 1.0);
#endif
glMatrixMode(GL_MODELVIEW);
@@ -883,7 +883,7 @@ void MobileOpenGLGraphics::_beginDraw()
// glScalef(0.5f, 0.5f, 0.5f);
- pushClipArea(gcn::Rectangle(0, 0, mWindow->w, mWindow->h));
+ pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h));
}
void MobileOpenGLGraphics::_endDraw()
@@ -894,13 +894,13 @@ void MobileOpenGLGraphics::_endDraw()
void MobileOpenGLGraphics::prepareScreenshot()
{
if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(mWindow->w, mWindow->h, &mFbo);
+ graphicsManager.createFBO(mRect.w, mRect.h, &mFbo);
}
SDL_Surface* MobileOpenGLGraphics::getScreenshot()
{
- const int h = mWindow->h;
- const int w = mWindow->w - (mWindow->w % 4);
+ const int h = mRect.h;
+ const int w = mRect.w - (mRect.w % 4);
GLint pack = 1;
SDL_Surface *const screenshot = SDL_CreateRGBSurface(
@@ -971,7 +971,7 @@ bool MobileOpenGLGraphics::pushClipArea(gcn::Rectangle area)
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
}
- glScissor(clipArea.x, mWindow->h - clipArea.y - clipArea.height,
+ glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
clipArea.width, clipArea.height);
return result;
@@ -986,7 +986,7 @@ void MobileOpenGLGraphics::popClipArea()
glPopMatrix();
const gcn::ClipRectangle &clipArea = mClipStack.top();
- glScissor(clipArea.x, mWindow->h - clipArea.y - clipArea.height,
+ glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
clipArea.width, clipArea.height);
}
diff --git a/src/normalopenglgraphics.cpp b/src/normalopenglgraphics.cpp
index ac933a6ac..089077224 100644
--- a/src/normalopenglgraphics.cpp
+++ b/src/normalopenglgraphics.cpp
@@ -1052,12 +1052,15 @@ void NormalOpenGLGraphics::_beginDraw()
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
+ const int w = mRect.w;
+ const int h = mRect.h;
+
#ifdef ANDROID
- glOrthof(0.0, static_cast<float>(mWindow->w),
- static_cast<float>(mWindow->h), 0.0, -1.0, 1.0);
+ glOrthof(0.0, static_cast<float>(w), static_cast<float>(h),
+ 0.0, -1.0, 1.0);
#else
- glOrtho(0.0, static_cast<double>(mWindow->w),
- static_cast<double>(mWindow->h), 0.0, -1.0, 1.0);
+ glOrtho(0.0, static_cast<double>(w), static_cast<double>(h),
+ 0.0, -1.0, 1.0);
#endif
glMatrixMode(GL_MODELVIEW);
@@ -1092,7 +1095,7 @@ void NormalOpenGLGraphics::_beginDraw()
// glScalef(0.5f, 0.5f, 0.5f);
- pushClipArea(gcn::Rectangle(0, 0, mWindow->w, mWindow->h));
+ pushClipArea(gcn::Rectangle(0, 0, w, h));
}
void NormalOpenGLGraphics::_endDraw()
@@ -1103,13 +1106,13 @@ void NormalOpenGLGraphics::_endDraw()
void NormalOpenGLGraphics::prepareScreenshot()
{
if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(mWindow->w, mWindow->h, &mFbo);
+ graphicsManager.createFBO(mRect.w, mRect.h, &mFbo);
}
SDL_Surface* NormalOpenGLGraphics::getScreenshot()
{
- const int h = mWindow->h;
- const int w = mWindow->w - (mWindow->w % 4);
+ const int h = mRect.h;
+ const int w = mRect.w - (mRect.w % 4);
GLint pack = 1;
SDL_Surface *const screenshot = SDL_CreateRGBSurface(
@@ -1181,7 +1184,7 @@ bool NormalOpenGLGraphics::pushClipArea(gcn::Rectangle area)
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
}
- glScissor(clipArea.x, mWindow->h - clipArea.y - clipArea.height,
+ glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
clipArea.width, clipArea.height);
return result;
@@ -1196,7 +1199,7 @@ void NormalOpenGLGraphics::popClipArea()
glPopMatrix();
const gcn::ClipRectangle &clipArea = mClipStack.top();
- glScissor(clipArea.x, mWindow->h - clipArea.y - clipArea.height,
+ glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
clipArea.width, clipArea.height);
}
diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp
index f6cd23de4..2388856c1 100644
--- a/src/resources/atlasmanager.cpp
+++ b/src/resources/atlasmanager.cpp
@@ -224,14 +224,16 @@ SDL_Surface *AtlasManager::createSDLAtlas(TextureAtlas *const atlas)
atlas->width = powerOfTwo(atlas->width);
atlas->height = powerOfTwo(atlas->height);
+ const int width = atlas->width;
+ const int height = atlas->height;
// temp SDL surface for atlas
SDL_Surface *const surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
- atlas->width, atlas->height, 32, rmask, gmask, bmask, amask);
+ width, height, 32, rmask, gmask, bmask, amask);
if (!surface)
return nullptr;
SDLGraphics *const graphics = new SDLGraphics();
- graphics->setWindow(surface);
+ graphics->setWindow(surface, width, height);
graphics->_beginDraw();
// drawing SDL images to surface
diff --git a/src/safeopenglgraphics.cpp b/src/safeopenglgraphics.cpp
index f04ffb3bc..fcb97a398 100644
--- a/src/safeopenglgraphics.cpp
+++ b/src/safeopenglgraphics.cpp
@@ -401,8 +401,8 @@ void SafeOpenGLGraphics::_beginDraw()
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- glOrtho(0.0, static_cast<double>(mWindow->w),
- static_cast<double>(mWindow->h), 0.0, -1.0, 1.0);
+ glOrtho(0.0, static_cast<double>(mRect.w),
+ static_cast<double>(mRect.h), 0.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@@ -420,7 +420,7 @@ void SafeOpenGLGraphics::_beginDraw()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- pushClipArea(gcn::Rectangle(0, 0, mWindow->w, mWindow->h));
+ pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h));
}
void SafeOpenGLGraphics::_endDraw()
@@ -431,13 +431,13 @@ void SafeOpenGLGraphics::_endDraw()
void SafeOpenGLGraphics::prepareScreenshot()
{
if (config.getBoolValue("usefbo"))
- graphicsManager.createFBO(mWindow->w, mWindow->h, &mFbo);
+ graphicsManager.createFBO(mRect.w, mRect.h, &mFbo);
}
SDL_Surface* SafeOpenGLGraphics::getScreenshot()
{
- const int h = mWindow->h;
- const int w = mWindow->w - (mWindow->w % 4);
+ const int h = mRect.h;
+ const int w = mRect.w - (mRect.w % 4);
GLint pack = 1;
SDL_Surface *const screenshot = SDL_CreateRGBSurface(
@@ -504,7 +504,7 @@ bool SafeOpenGLGraphics::pushClipArea(gcn::Rectangle area)
glPushMatrix();
glTranslatef(static_cast<GLfloat>(transX),
static_cast<GLfloat>(transY), 0);
- glScissor(clipArea.x, mWindow->h - clipArea.y - clipArea.height,
+ glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
clipArea.width, clipArea.height);
return result;
@@ -519,7 +519,7 @@ void SafeOpenGLGraphics::popClipArea()
glPopMatrix();
const gcn::ClipRectangle &clipArea = mClipStack.top();
- glScissor(clipArea.x, mWindow->h - clipArea.y - clipArea.height,
+ glScissor(clipArea.x, mRect.h - clipArea.y - clipArea.height,
clipArea.width, clipArea.height);
}
diff --git a/src/sdl2graphics.cpp b/src/sdl2graphics.cpp
index 99f022bcb..a2fc010f6 100644
--- a/src/sdl2graphics.cpp
+++ b/src/sdl2graphics.cpp
@@ -434,7 +434,7 @@ SDL_Surface *SDLGraphics::getScreenshot()
const int amask = 0x00000000;
SDL_Surface *const screenshot = SDL_CreateRGBSurface(SDL_SWSURFACE,
- mWindow->w, mWindow->h, 24, rmask, gmask, bmask, amask);
+ mRect.w, mRect.h, 24, rmask, gmask, bmask, amask);
if (screenshot)
SDL_BlitSurface(mWindow, nullptr, screenshot, nullptr);
@@ -782,7 +782,7 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle)
void SDLGraphics::_beginDraw()
{
- pushClipArea(gcn::Rectangle(0, 0, mWindow->w, mWindow->h));
+ pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h));
}
void SDLGraphics::_endDraw()
@@ -1141,6 +1141,8 @@ bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp,
if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
getSoftwareFlags())))
{
+ mRect.w = 0;
+ mRect.h = 0;
return false;
}
diff --git a/src/sdlgraphics.cpp b/src/sdlgraphics.cpp
index 6bc196cd9..38984593c 100644
--- a/src/sdlgraphics.cpp
+++ b/src/sdlgraphics.cpp
@@ -434,7 +434,7 @@ SDL_Surface *SDLGraphics::getScreenshot()
const int amask = 0x00000000;
SDL_Surface *const screenshot = SDL_CreateRGBSurface(SDL_SWSURFACE,
- mWindow->w, mWindow->h, 24, rmask, gmask, bmask, amask);
+ mRect.w, mRect.h, 24, rmask, gmask, bmask, amask);
if (screenshot)
SDL_BlitSurface(mWindow, nullptr, screenshot, nullptr);
@@ -782,7 +782,7 @@ void SDLGraphics::fillRectangle(const gcn::Rectangle& rectangle)
void SDLGraphics::_beginDraw()
{
- pushClipArea(gcn::Rectangle(0, 0, mWindow->w, mWindow->h));
+ pushClipArea(gcn::Rectangle(0, 0, mRect.w, mRect.h));
}
void SDLGraphics::_endDraw()
@@ -1141,6 +1141,8 @@ bool SDLGraphics::setVideoMode(const int w, const int h, const int bpp,
if (!(mWindow = graphicsManager.createWindow(w, h, bpp,
getSoftwareFlags())))
{
+ mRect.w = 0;
+ mRect.h = 0;
return false;
}