summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-10-15 19:51:19 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-10-15 19:51:19 +0000
commit1724d87c2271e18e9349abce5a3eebec5ec72f6d (patch)
treebbaf328ff952fb074e3c319979ef9f5339a57a98 /src/resources
parent555c7481ba83971f8ce95b1e80caeabf3dc26ff4 (diff)
downloadmana-1724d87c2271e18e9349abce5a3eebec5ec72f6d.tar.gz
mana-1724d87c2271e18e9349abce5a3eebec5ec72f6d.tar.bz2
mana-1724d87c2271e18e9349abce5a3eebec5ec72f6d.tar.xz
mana-1724d87c2271e18e9349abce5a3eebec5ec72f6d.zip
Some small cleanups.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/image.cpp21
-rw-r--r--src/resources/image.h2
2 files changed, 9 insertions, 14 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 266f46e3..52b6f447 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -32,11 +32,9 @@ bool Image::mUseOpenGL = false;
#endif
Image::Image(const std::string &idPath, SDL_Surface *image):
- Resource(idPath), mImage(image)
+ Resource(idPath), mImage(image),
+ mAlpha(1.0f)
{
- // Default to opaque
- alpha = 1.0f;
-
bounds.x = 0;
bounds.y = 0;
bounds.w = mImage->w;
@@ -49,11 +47,9 @@ Image::Image(const std::string &idPath, GLuint glimage, int width, int height,
Resource(idPath),
mGLImage(glimage),
mTexWidth(texWidth),
- mTexHeight(texHeight)
+ mTexHeight(texHeight),
+ mAlpha(1.0f)
{
- // Default to opaque
- alpha = 1.0f;
-
bounds.x = 0;
bounds.y = 0;
bounds.w = width;
@@ -243,14 +239,13 @@ Image* Image::load(void *buffer, unsigned int bufferSize,
// Set color key and alpha blending optins, and convert the surface to the
// current display format
- SDL_Surface *prevImage = tmpImage;
if (hasAlpha) {
image = SDL_DisplayFormatAlpha(tmpImage);
}
else {
image = SDL_DisplayFormat(tmpImage);
}
- SDL_FreeSurface(prevImage);
+ SDL_FreeSurface(tmpImage);
if (image == NULL) {
logger->log("Error: Image convert failed.");
@@ -290,7 +285,7 @@ Image *Image::getSubImage(int x, int y, int width, int height)
void Image::setAlpha(float a)
{
- alpha = a;
+ mAlpha = a;
#ifdef USE_OPENGL
if (mUseOpenGL) {
@@ -299,12 +294,12 @@ void Image::setAlpha(float a)
#endif
// Set the alpha value this image is drawn at
- SDL_SetAlpha(mImage, SDL_SRCALPHA | SDL_RLEACCEL, (int)(255 * alpha));
+ SDL_SetAlpha(mImage, SDL_SRCALPHA | SDL_RLEACCEL, (int)(255 * mAlpha));
}
float Image::getAlpha()
{
- return alpha;
+ return mAlpha;
}
#ifdef USE_OPENGL
diff --git a/src/resources/image.h b/src/resources/image.h
index a7d5cdf1..44142155 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -129,7 +129,7 @@ class Image : public Resource
static bool mUseOpenGL;
#endif
SDL_Surface *mImage;
- float alpha;
+ float mAlpha;
};
/**