summaryrefslogtreecommitdiff
path: root/src/render/safeopenglgraphics.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-12-30 14:17:37 +0300
committerAndrei Karas <akaras@inbox.ru>2013-12-30 14:17:37 +0300
commit31fcdb31fb406531bec49ee2d1b3cc286ed3b5a8 (patch)
treeb7f2a06054bacc8208d8fb429fc811ed199b4453 /src/render/safeopenglgraphics.cpp
parent74f89c500d278b6ac668c313b63d0f1e76f4acaf (diff)
downloadmv-31fcdb31fb406531bec49ee2d1b3cc286ed3b5a8.tar.gz
mv-31fcdb31fb406531bec49ee2d1b3cc286ed3b5a8.tar.bz2
mv-31fcdb31fb406531bec49ee2d1b3cc286ed3b5a8.tar.xz
mv-31fcdb31fb406531bec49ee2d1b3cc286ed3b5a8.zip
Improve drawRescaledImage in renderers.
Diffstat (limited to 'src/render/safeopenglgraphics.cpp')
-rw-r--r--src/render/safeopenglgraphics.cpp59
1 files changed, 9 insertions, 50 deletions
diff --git a/src/render/safeopenglgraphics.cpp b/src/render/safeopenglgraphics.cpp
index 614c4158c..f92455e58 100644
--- a/src/render/safeopenglgraphics.cpp
+++ b/src/render/safeopenglgraphics.cpp
@@ -221,70 +221,29 @@ void SafeOpenGLGraphics::completeCache()
{
}
-bool SafeOpenGLGraphics::drawRescaledImage(const Image *const image, int srcX,
- int srcY, int dstX, int dstY,
- const int width, const int height,
+bool SafeOpenGLGraphics::drawRescaledImage(const Image *const image,
+ int dstX, int dstY,
const int desiredWidth,
- const int desiredHeight,
- const bool useColor)
-{
- return drawRescaledImage(image, srcX, srcY,
- dstX, dstY,
- width, height,
- desiredWidth, desiredHeight,
- useColor, true);
-}
-
-bool SafeOpenGLGraphics::drawRescaledImage(const Image *const image, int srcX,
- int srcY, int dstX, int dstY,
- const int width, const int height,
- const int desiredWidth,
- const int desiredHeight,
- const bool useColor,
- bool smooth)
+ const int desiredHeight)
{
FUNC_BLOCK("Graphics::drawRescaledImage", 1)
if (!image)
return false;
+ const SDL_Rect &imageRect = image->mBounds;
+
// Just draw the image normally when no resizing is necessary,
- if (width == desiredWidth && height == desiredHeight)
+ if (imageRect.w == desiredWidth && imageRect.h == desiredHeight)
return drawImage2(image, dstX, dstY);
- // When the desired image is smaller than the current one,
- // disable smooth effect.
- if (width > desiredWidth && height > desiredHeight)
- smooth = false;
-
- srcX += image->mBounds.x;
- srcY += image->mBounds.y;
-
- if (!useColor)
- setColorAlpha(image->mAlpha);
-
+ setColorAlpha(image->mAlpha);
bindTexture(OpenGLImageHelper::mTextureType, image->mGLImage);
-
setTexturingAndBlending(true);
// Draw a textured quad.
glBegin(GL_QUADS);
- drawRescaledQuad(image, srcX, srcY, dstX, dstY, width, height,
- desiredWidth, desiredHeight);
-
- if (smooth) // A basic smooth effect...
- {
- setColorAlpha(0.2F);
- drawRescaledQuad(image, srcX, srcY, dstX - 1, dstY - 1, width, height,
- desiredWidth + 1, desiredHeight + 1);
- drawRescaledQuad(image, srcX, srcY, dstX + 1, dstY + 1, width, height,
- desiredWidth - 1, desiredHeight - 1);
-
- drawRescaledQuad(image, srcX, srcY, dstX + 1, dstY, width, height,
- desiredWidth - 1, desiredHeight);
- drawRescaledQuad(image, srcX, srcY, dstX, dstY + 1, width, height,
- desiredWidth, desiredHeight - 1);
- }
-
+ drawRescaledQuad(image, imageRect.x, imageRect.y, dstX, dstY,
+ imageRect.w, imageRect.h, desiredWidth, desiredHeight);
glEnd();
return true;