summaryrefslogtreecommitdiff
path: root/src
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
parent555c7481ba83971f8ce95b1e80caeabf3dc26ff4 (diff)
downloadmana-1724d87c2271e18e9349abce5a3eebec5ec72f6d.tar.gz
mana-1724d87c2271e18e9349abce5a3eebec5ec72f6d.tar.bz2
mana-1724d87c2271e18e9349abce5a3eebec5ec72f6d.tar.xz
mana-1724d87c2271e18e9349abce5a3eebec5ec72f6d.zip
Some small cleanups.
Diffstat (limited to 'src')
-rw-r--r--src/openglgraphics.cpp2
-rw-r--r--src/resources/image.cpp21
-rw-r--r--src/resources/image.h2
3 files changed, 10 insertions, 15 deletions
diff --git a/src/openglgraphics.cpp b/src/openglgraphics.cpp
index 983c948e..efe875bc 100644
--- a/src/openglgraphics.cpp
+++ b/src/openglgraphics.cpp
@@ -94,7 +94,7 @@ bool OpenGLGraphics::drawImage(Image *image, int srcX, int srcY,
float texX2 = (srcX + width) / (float)image->mTexWidth;
float texY2 = (srcY + height) / (float)image->mTexHeight;
- glColor4f(1.0f, 1.0f, 1.0f, image->alpha);
+ glColor4f(1.0f, 1.0f, 1.0f, image->mAlpha);
glBindTexture(GL_TEXTURE_2D, image->mGLImage);
drawTexedQuad(dstX, dstY, width, height, texX1, texY1, texX2, texY2);
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;
};
/**