summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog2
-rw-r--r--src/openglgraphics.cpp2
-rw-r--r--src/resources/image.cpp21
-rw-r--r--src/resources/image.h2
4 files changed, 12 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 4cd759b3..037c87df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2005-10-15 Björn Steinbrink <B.Steinbrink@gmx.de>
+ * src/openglgraphics.cpp, src/resources/image.cpp,
+ src/resources/image.h: Some small cleanups.
* src/engine.cpp: Removed some legacy debug code.
2005-10-13 Bjørn Lindeijer <bjorn@lindeijer.nl>
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;
};
/**