summaryrefslogtreecommitdiff
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
parent3f21f53869044e5928ed2407a48ac28835da1cb1 (diff)
downloadmana-35979e4ee13898d99f16b2777292d257e91f8bf2.tar.gz
mana-35979e4ee13898d99f16b2777292d257e91f8bf2.tar.bz2
mana-35979e4ee13898d99f16b2777292d257e91f8bf2.tar.xz
mana-35979e4ee13898d99f16b2777292d257e91f8bf2.zip
Changed mImage member to mSDLSurface as it is SDL specific...
-rw-r--r--src/graphics.cpp36
-rw-r--r--src/resources/image.cpp36
-rw-r--r--src/resources/image.h2
3 files changed, 39 insertions, 35 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);
}
}
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index b51e1e1e..408668eb 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -38,13 +38,13 @@ Image::Image(SDL_Surface *image):
#ifdef USE_OPENGL
mGLImage(0),
#endif
- mImage(image),
+ mSDLSurface(image),
mAlpha(1.0f)
{
mBounds.x = 0;
mBounds.y = 0;
- mBounds.w = mImage->w;
- mBounds.h = mImage->h;
+ mBounds.w = mSDLSurface->w;
+ mBounds.h = mSDLSurface->h;
}
#ifdef USE_OPENGL
@@ -52,7 +52,7 @@ Image::Image(GLuint glimage, int width, int height, int texWidth, int texHeight)
mGLImage(glimage),
mTexWidth(texWidth),
mTexHeight(texHeight),
- mImage(0),
+ mSDLSurface(0),
mAlpha(1.0)
{
mBounds.x = 0;
@@ -144,11 +144,11 @@ void Image::unload()
{
mLoaded = false;
- if (mImage)
+ if (mSDLSurface)
{
// Free the image surface.
- SDL_FreeSurface(mImage);
- mImage = NULL;
+ SDL_FreeSurface(mSDLSurface);
+ mSDLSurface = NULL;
}
#ifdef USE_OPENGL
@@ -176,27 +176,27 @@ void Image::setAlpha(float a)
mAlpha = a;
- if (mImage)
+ if (mSDLSurface)
{
// Set the alpha value this image is drawn at
- SDL_SetAlpha(mImage, SDL_SRCALPHA, (int) (255 * mAlpha));
+ SDL_SetAlpha(mSDLSurface, SDL_SRCALPHA, (int) (255 * mAlpha));
}
}
Image* Image::SDLmerge(Image *image, int x, int y)
{
- SDL_Surface* surface = new SDL_Surface(*(image->mImage));
+ SDL_Surface* surface = new SDL_Surface(*(image->mSDLSurface));
Uint32 surface_pix, cur_pix;
Uint8 r, g, b, a, p_r, p_g, p_b, p_a;
double f_a, f_ca, f_pa;
- SDL_PixelFormat *current_fmt = mImage->format;
+ SDL_PixelFormat *current_fmt = mSDLSurface->format;
SDL_PixelFormat *surface_fmt = surface->format;
int current_offset, surface_offset;
int offset_x, offset_y;
SDL_LockSurface(surface);
- SDL_LockSurface(mImage);
+ SDL_LockSurface(mSDLSurface);
// for each pixel lines of a source image
for (offset_x = (x > 0 ? 0 : -x); offset_x < image->getWidth() &&
x + offset_x < getWidth(); offset_x++)
@@ -210,7 +210,7 @@ Image* Image::SDLmerge(Image *image, int x, int y)
// Retrieving a pixel to merge
surface_pix = ((Uint32*) surface->pixels)[surface_offset];
- cur_pix = ((Uint32*) mImage->pixels)[current_offset];
+ cur_pix = ((Uint32*) mSDLSurface->pixels)[current_offset];
// Retreiving each channel of the pixel using pixel format
r = (Uint8)(((surface_pix & surface_fmt->Rmask) >>
@@ -251,7 +251,7 @@ Image* Image::SDLmerge(Image *image, int x, int y)
}
}
SDL_UnlockSurface(surface);
- SDL_UnlockSurface(mImage);
+ SDL_UnlockSurface(mSDLSurface);
Image *newImage = new Image(surface);
@@ -271,9 +271,9 @@ Image* Image::SDLgetScaledImage(int width, int height)
Image* scaledImage = NULL;
SDL_Surface* scaledSurface = NULL;
- if (mImage)
+ if (mSDLSurface)
{
- scaledSurface = _SDLzoomSurface(mImage,
+ scaledSurface = _SDLzoomSurface(mSDLSurface,
(double) width / getWidth(),
(double) height / getHeight(),
1);
@@ -463,7 +463,7 @@ Image *Image::getSubImage(int x, int y, int width, int height)
mTexWidth, mTexHeight);
#endif
- return new SubImage(this, mImage, x, y, width, height);
+ return new SubImage(this, mSDLSurface, x, y, width, height);
}
//============================================================================
@@ -504,7 +504,7 @@ SubImage::SubImage(Image *parent, GLuint image,
SubImage::~SubImage()
{
// Avoid destruction of the image
- mImage = 0;
+ mSDLSurface = 0;
#ifdef USE_OPENGL
mGLImage = 0;
#endif
diff --git a/src/resources/image.h b/src/resources/image.h
index 824881a3..91ecbb54 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -186,7 +186,7 @@ class Image : public Resource
static Image *_SDLload(SDL_Surface *tmpImage);
- SDL_Surface *mImage;
+ SDL_Surface *mSDLSurface;
// -----------------------