summaryrefslogtreecommitdiff
path: root/src/graphics.cpp
diff options
context:
space:
mode:
authorBertram <bertram@cegetel.net>2009-08-13 20:21:54 +0200
committerBertram <bertram@cegetel.net>2009-08-13 20:21:54 +0200
commit35979e4ee13898d99f16b2777292d257e91f8bf2 (patch)
treeb1a2058ac8953417951fde34b7cdb476ba85ba9c /src/graphics.cpp
parent3f21f53869044e5928ed2407a48ac28835da1cb1 (diff)
downloadmana-client-35979e4ee13898d99f16b2777292d257e91f8bf2.tar.gz
mana-client-35979e4ee13898d99f16b2777292d257e91f8bf2.tar.bz2
mana-client-35979e4ee13898d99f16b2777292d257e91f8bf2.tar.xz
mana-client-35979e4ee13898d99f16b2777292d257e91f8bf2.zip
Changed mImage member to mSDLSurface as it is SDL specific...
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r--src/graphics.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp
index 75db11f4..14a2b852 100644
--- a/src/graphics.cpp
+++ b/src/graphics.cpp
@@ -117,7 +117,10 @@ int Graphics::getHeight() const
bool Graphics::drawImage(Image *image, int x, int y)
{
- return drawImage(image, 0, 0, x, y, image->mBounds.w, image->mBounds.h);
+ if (image)
+ return drawImage(image, 0, 0, x, y, image->mBounds.w, image->mBounds.h);
+ else
+ return false;
}
bool Graphics::drawRescaledImage(Image *image, int srcX, int srcY,
@@ -128,12 +131,13 @@ bool Graphics::drawRescaledImage(Image *image, int srcX, int srcY,
{
// Check that preconditions for blitting are met.
if (!mScreen || !image) return false;
- if (!image->mImage) return false;
+ if (!image->mSDLSurface) return false;
Image *tmpImage = image->SDLgetScaledImage(desiredWidth, desiredHeight);
bool returnValue = false;
+
if (!tmpImage) return false;
- if (!tmpImage->mImage) return false;
+ if (!tmpImage->mSDLSurface) return false;
dstX += mClipStack.top().xOffset;
dstY += mClipStack.top().yOffset;
@@ -148,7 +152,7 @@ bool Graphics::drawRescaledImage(Image *image, int srcX, int srcY,
srcRect.w = width;
srcRect.h = height;
- returnValue = !(SDL_BlitSurface(tmpImage->mImage, &srcRect, mScreen, &dstRect) < 0);
+ returnValue = !(SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect, mScreen, &dstRect) < 0);
delete tmpImage;
@@ -160,7 +164,7 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
{
// Check that preconditions for blitting are met.
if (!mScreen || !image) return false;
- if (!image->mImage) return false;
+ if (!image->mSDLSurface) return false;
dstX += mClipStack.top().xOffset;
dstY += mClipStack.top().yOffset;
@@ -175,7 +179,7 @@ bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY,
srcRect.w = width;
srcRect.h = height;
- return !(SDL_BlitSurface(image->mImage, &srcRect, mScreen, &dstRect) < 0);
+ return !(SDL_BlitSurface(image->mSDLSurface, &srcRect, mScreen, &dstRect) < 0);
}
void Graphics::drawImage(gcn::Image const *image, int srcX, int srcY,
@@ -191,12 +195,12 @@ void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
{
// Check that preconditions for blitting are met.
if (!mScreen || !image) return;
- if (!image->mImage) return;
+ if (!image->mSDLSurface) return;
const int iw = image->getWidth();
const int ih = image->getHeight();
-
- if (iw == 0 || ih == 0) return;
+
+ if (iw == 0 || ih == 0) return;
for (int py = 0; py < h; py += ih) // Y position on pattern plane
{
@@ -204,7 +208,7 @@ void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
int srcY = image->mBounds.y;
int dstY = y + py + mClipStack.top().yOffset;
- for (int px = 0; px < w; px += iw) // X position on pattern plane
+ for (int px = 0; px < w; px += iw) // X position on pattern plane
{
int dw = (px + iw >= w) ? w - px : iw;
int srcX = image->mBounds.x;
@@ -216,7 +220,7 @@ void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h)
srcRect.x = srcX; srcRect.y = srcY;
srcRect.w = dw; srcRect.h = dh;
- SDL_BlitSurface(image->mImage, &srcRect, mScreen, &dstRect);
+ SDL_BlitSurface(image->mSDLSurface, &srcRect, mScreen, &dstRect);
}
}
}
@@ -226,7 +230,7 @@ void Graphics::drawRescaledImagePattern(Image *image, int x, int y,
{
// Check that preconditions for blitting are met.
if (!mScreen || !image) return;
- if (!image->mImage) return;
+ if (!image->mSDLSurface) return;
if (scaledHeight == 0 || scaledWidth == 0) return;
@@ -235,8 +239,8 @@ void Graphics::drawRescaledImagePattern(Image *image, int x, int y,
const int iw = tmpImage->getWidth();
const int ih = tmpImage->getHeight();
-
- if (iw == 0 || ih == 0) return;
+
+ if (iw == 0 || ih == 0) return;
for (int py = 0; py < h; py += ih) // Y position on pattern plane
{
@@ -244,7 +248,7 @@ void Graphics::drawRescaledImagePattern(Image *image, int x, int y,
int srcY = tmpImage->mBounds.y;
int dstY = y + py + mClipStack.top().yOffset;
- for (int px = 0; px < w; px += iw) // X position on pattern plane
+ for (int px = 0; px < w; px += iw) // X position on pattern plane
{
int dw = (px + iw >= w) ? w - px : iw;
int srcX = tmpImage->mBounds.x;
@@ -256,7 +260,7 @@ void Graphics::drawRescaledImagePattern(Image *image, int x, int y,
srcRect.x = srcX; srcRect.y = srcY;
srcRect.w = dw; srcRect.h = dh;
- SDL_BlitSurface(tmpImage->mImage, &srcRect, mScreen, &dstRect);
+ SDL_BlitSurface(tmpImage->mSDLSurface, &srcRect, mScreen, &dstRect);
}
}